Throwing something else out there: looking at d_soundfiler.c, it looks like it 
wouldn’t be that hard to add a second outlet that could send out the number of 
channels and samplerate of the loaded file. As far as I can tell, the number of 
channels is already read, so it involves reading the samplerate. This would 
allow for the calculation of the correct playback speed for samples 
irregardless of source & playback samplerates.

WAVE:

The samplerate is the 4 bytes after the number of channels in the WAVE fmt 
chunk. Ref: http://www.lightlink.com/tjweber/StripWav/Canon.html 
<http://www.lightlink.com/tjweber/StripWav/Canon.html>

AIFF:

The samplerate is the last field in the COMM (Common) chunk. 
 
typedef struct {

     ID              ckID;
     long           ckSize;
     short          numChannels;
     unsigned long  numSampleFrames;
     short          sampleSize;
     extended   sampleRate;

}  CommonChunk;

Ref: 
http://www-mmsp.ece.mcgill.ca/documents/audioformats/aiff/Docs/AIFF-1.3.pdf 
<http://www-mmsp.ece.mcgill.ca/documents/audioformats/aiff/Docs/AIFF-1.3.pdf>

--------
Dan Wilcox
@danomatika <https://twitter.com/danomatika>
danomatika.com <http://danomatika.com/>
robotcowboy.com <http://robotcowboy.com/>
_______________________________________________
Pd-dev mailing list
[email protected]
http://lists.puredata.info/listinfo/pd-dev

Reply via email to