Hello All, I'm writing a little audio player that plays voicemail files. (I realize I'm reinventing the wheel, but it's still fun.)
The problem I'm experiencing is that I'm hearing the last fraction of the sound clip twice, either when the clip is done playing or when the program exits. I've tried a few things and none of them have worked. The bit of code that does the playing is here: def play(self): if self.data_written < self.file_length: buf = self.data.read(self.buf_size) self.data_written += self.dsp.write(buf) self.percent_done = self.data_written / self.file_length if self.data_written == self.file_length: self._reopen_audio_device() This causes the second playing of the "last little bit" when the end of the file is reached. When I don't include the second if statement, the "last little bit" gets played when the program exits. According to the documentaiton, closing the audio device will flush any data in the sound card buffer. I guess what I'm hearing is that buffered clip being flushed. I've thought about using the mixer device to put the volume to zero, flush the buffer, then turning the volume back up again, but that seems like a hack. If anyone decides to use this program, you'll need to use a .wav file and change the value of self.sample_rate in vmPlayer.py from 8000 to 44100 (or whatever rate your file is encoded in) (Also, I plan on auto-detecting the sample rate in the future. I hard coded 8000 because that's the rate the voice mail system uses.) See attached files for the code. -mtw
player_py.RENAMED_BY_TTSD-0
Description: application/renamed_by_ttsd-0
vmPlayer_py.RENAMED_BY_TTSD-2
Description: application/renamed_by_ttsd-2
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor