11
11
* WITHOUT ANY WARRANTY; without even the implied warranty of
12
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
13
* Library General Public License for more details.
15
15
* You should have received a copy of the GNU Library General Public
16
16
* License along with this library; if not, write to the Free
17
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
82
82
dev = FLUID_NEW(fluid_file_audio_driver_t);
84
84
FLUID_LOG(FLUID_ERR, "Out of memory");
87
87
FLUID_MEMSET(dev, 0, sizeof(fluid_file_audio_driver_t));
157
157
static int fluid_file_audio_run_s16(void* d, unsigned int clock_time)
159
159
fluid_file_audio_driver_t* dev = (fluid_file_audio_driver_t*) d;
163
161
unsigned int sample_time;
165
handle[0] = dev->left;
166
handle[1] = dev->right;
169
163
sample_time = (unsigned int) (dev->samples / dev->sample_rate * 1000.0);
170
164
if (sample_time > clock_time) {
174
(*dev->callback)(dev->data, dev->period_size, 0, NULL, 2, handle);
176
for (i = 0, k = 0; i < dev->period_size; i++, k += 2) {
177
s = 32768.0f * dev->left[i];
178
fluid_clip(s, -32768.0f, 32767.0f);
179
dev->buf[k] = (short) s;
182
for (i = 0, k = 1; i < dev->period_size; i++, k += 2) {
183
s = 32768.0f * dev->right[i];
184
fluid_clip(s, -32768.0f, 32767.0f);
185
dev->buf[k] = (short) s;
168
fluid_synth_write_s16(dev->data, dev->period_size, dev->buf, 0, 2, dev->buf, 1, 2);
188
170
for (offset = 0; offset < dev->buf_size; offset += n) {
190
172
n = fwrite((char*) dev->buf + offset, 1, dev->buf_size - offset, dev->file);
192
FLUID_LOG(FLUID_ERR, "Audio file error");
174
FLUID_LOG(FLUID_ERR, "Audio output file write error: %s",
197
180
dev->samples += dev->period_size;