[Tutor] Can I have some assistance understanding the wave module

Alan Gauld alan.gauld at yahoo.co.uk
Mon Oct 10 14:08:10 EDT 2022


On 10/10/2022 17:03, Nathan Smith wrote:

> So I am trying to work with the wave module, with the end goal of taking 
> raw data from an audio CD and writing it to a Wav file.

Caveat: I have no experience with the wave module I just
read the docs....


> file.setsampwidth: What actually is this? It seems to except a number 
> between 1 and 4, but 4 produces a file that is 46 seconds long off disc 
> (but only 24 on disc).

The docs say the number is the sample size in bytes. So a 4 means you
are writing 4 byte = 32 bit samples. Maybe the original file was using
16 bit?

> To that end, is this related to bit depth? Audio CD's are recorded at an 
> sr of 44100, and a bit depth of 16, but this being the case, can python'
> s wave module not handle this?

Based on the documentation you would need a samplesize of 2.
Documentation is really useful. :-)

-- 
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.amazon.com/author/alan_gauld
Follow my photo-blog on Flickr at:
http://www.flickr.com/photos/alangauldphotos






More information about the Tutor mailing list