2 TiMidity++ -- MIDI to WAVE converter and player
3 Copyright (C) 1999-2002 Masanao Izumo <mo@goice.co.jp>
4 Copyright (C) 1995 Tuukka Toivonen <tt@cgs.fi>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 Functions to output raw sound data to a file or stdout.
28 #endif /* HAVE_CONFIG_H */
32 #include <sys/types.h>
42 #endif /* HAVE_UNISTD_H */
67 static int open_output(void); /* 0=success, 1=warning, -1=fatal error */
68 static void close_output(void);
69 static int output_data(const uint8 *buf, size_t bytes);
70 static int acntl(int request, void *arg);
72 /* export the playback mode */
74 #define dpm benchmark_mode
77 DEFAULT_RATE, PE_16BIT|PE_SIGNED, PF_PCM_STREAM|PF_FILE_OUTPUT,
88 static double counter = 0.0, time_elapsed = 0.0;
91 /*************************************************************************/
93 static int silent_output_open(void)
95 dpm.flag |= PF_AUTO_SPLIT_FILE;
101 static int open_output(void)
103 silent_output_open();
107 static int output_data(const uint8 *buf, size_t bytes)
112 time_elapsed = get_current_calender_time() - counter;
116 counter = get_current_calender_time();
118 ctl->cmsg(CMSG_INFO, VERB_NORMAL,
119 "%s: First output", dpm.id_name);
123 static void close_output(void)
126 ctl->cmsg(CMSG_INFO, VERB_NORMAL,
127 "%s: Time elapsed : %.2f sec", dpm.id_name,
128 (double)(time_elapsed));
134 static int acntl(int request, void *arg)
137 case PM_REQ_PLAY_START:
138 if (dpm.flag & PF_AUTO_SPLIT_FILE) {
139 return silent_output_open();
142 case PM_REQ_PLAY_END:
143 if(dpm.flag & PF_AUTO_SPLIT_FILE)