digego / extempore

A cyber-physical programming environment
1.4k stars 127 forks source link

audiobuffer stereo frame length #233

Closed algomusic closed 8 years ago

algomusic commented 8 years ago

When working with the audiobuffer.xtm library reading mono files seems fine, but stereo files seem to read only parial data - or at least the frame count is incorrect. Below is text code that shows the difference in playback length when run with either a stereo (short) or mono (okay) file. (Test done with 16/44.1 aif files).

(sys:load "libs/core/audio_dsp.xtm") (sys:load "libs/core/audiobuffer.xtm")

(bind-func dsp (let ((buffer (AudioBuffer_from_aiff "/Users/s978684/Google\ Drive/Code/Extempore/Designing-Soundexamples/Samples/Ello-mono.aif")) (audio-data (tref buffer 4)) (channels (tref buffer 3)) (frame1 (tref buffer 2)) (pos 0)) (lambda (in:SAMPLE time:i64 channel:i64 data:SAMPLE) (if (< channel channels) (set! pos (+ pos 1))) (if (< pos frames) (_ 1.0 (pref audio-data (% pos frames))) 0.0))))

(dsp:set! dsp)

(bind-func play (lambda () (dsp.pos 0)))

(play)

digego commented 8 years ago

total samples = frames * channels

On 12 January 2016 9:31:03 pm AEST, algomusic notifications@github.com wrote:

When working with the audiobuffer.xtm library reading mono files seems fine, but stereo files seem to read only parial data - or at least the frame count is incorrect. Below is text code that shows the difference in playbcak length when run with either a stereo (short) or mono (okay) file.

(sys:load "libs/core/audio_dsp.xtm") (sys:load "libs/core/audiobuffer.xtm")

(bind-func dsp (let ((buffer (AudioBuffer_from_aiff "/Users/s978684/Google\ Drive/Code/Extempore/Designing-Soundexamples/Samples/Ello-mono.aif")) (audio-data (tref buffer 4)) (channels (tref buffer 3)) (frame1 (tref buffer 2)) (pos 0)) (lambda (in:SAMPLE time:i64 channel:i64 data:SAMPLE) (if (< channel channels) (set! pos (+ pos 1))) (if (< pos frames) (_ 1.0 (pref audio-data (% pos frames))) 0.0))))

(dsp:set! dsp)

(bind-func play (lambda () (dsp.pos 0)))

(play)


Reply to this email directly or view it on GitHub: https://github.com/digego/extempore/issues/233

Sent from my Android device with K-9 Mail. Please excuse my brevity.

algomusic commented 8 years ago

Yes released to late to remove bug report before response - thanks.