tuffy / python-audio-tools

A collection of audio handling programs which work from the command line.
http://audiotools.sourceforge.net
GNU General Public License v2.0
249 stars 58 forks source link

Feature request: please support 32 bits_per_sample in PCMConverter #50

Open litolff opened 9 years ago

litolff commented 9 years ago

alsa-drivers for some intel core-i processors don't support 24 bits/sample but only 16 & 32 bits/sample. i want to avoid, degrading soundquality of my (expensive) high-Res audiofiles by converting from 24 to 16bits/sample.

Due to those hardware(driver) restriction, the audiotools,player.Player didn't play 24bit audiofiles(flac) at all.

When audio_out is set to audiotools,player.open_output('ALSA') this is what i get: File "/usr/lib/python3.4/site-packages/audiotools/player.py", line 992, in set_format bits_per_sample) OSError: unable to set ALSA stream parameters

tuffy commented 9 years ago

I've updated the ALSA output module to support 32-bit output for 24-bit input files and it appears to be working correctly on my system. Hopefully this will solve your playback issue.

litolff commented 9 years ago

I made 2 different approaches to use your library with 24bit files:

1.) using audiotools,player.Player gives: File "/usr/lib/python3.4/site-packages/audiotools/player.py", line 992, in set_format bits_per_sample) OSError: unable to attach ALSA mixer to card

2.) pcmReader = at.open(uri).to_pcm() mask = pcmReader.channel_mask pcmConverter = at.PCMConverter(pcmReader,96000,2, mask,32)#16 instead 32 works self.__pcmreader = at.BufferedPCMReader(pcmConverter)

gives: File "/usr/lib/python3.4/site-packages/audiotools/init.py", line 2965, in PCMConverter raise ValueError(ERR_INVALID_BITS_PER_SAMPLE) ValueError: invalid bits-per-sample

.asoundrc in my /home is: pcm.!default { type hw card 0 device 8 } ctl.!default { type hw
card 0 device 8 }

tuffy commented 9 years ago

Looks like your default ALSA device doesn't support mixers. I've updated my ALSA output module to work without them. This should hopefully enable proper playback, though volume control won't be accessible from within Python Audio Tools.

litolff commented 9 years ago

wow, that was fast, thank you very much ...proper playback enabled :-) tested with 24bit/48000Hz, 24bit/88200Hz and 24bit/96000Hz ...volume control is not necessary i'm one of those paranoid audiophils, looking for the shortest audiopath... no pulse, no mixer ;-)

although it's not vital anymore, would it be possible to support 32bit in PCMConverter ?