audio

Description

This part of fluxus is responsible for capturing the incoming sound, and processing it into harmonic data, using fft (Fast Fourier Transform). The harmonics are bands of frequency which the sound is split into, giving some indication of the quality of the sound. It's the same as you see on a graphic equaliser - in fact, one of the example scripts (bars.scm) acts as a graphic equaliser display, and should be used to test the audio is working.

Example

 (start-audio "alsa_pcm:capture_1" 1024 44100)
 (define (animate)
		(colour (vector (gh 1) (gh 2) (gh 3))) ; make a colour from the harmonics, and set it to be the current colour 
		(draw-cube)) ; draw a cube with this colour
 (every-frame (animate))

(start-audio jackport-string buffersize-number samplerate-number)

Returns void

Starts up the audio with the specified settings, you'll need to call this first, or put it into $HOME/.fluxus.scm to call it automatically at startup. Make the jack port name an empty string and it won't try to connect to anything for you. You can use qjackctrl or equivelent to do the connection manually. Fluxus reads a single mono source.

Example

 (start-audio "alsa_pcm:capture_1" 1024 44100)

(gh harmonic-number)

Returns harmonic-real

Fluxus converts incoming audio into harmonic frequencies, which can then be plugged into your animations using this command. There are 16 harmonic bands availible, the harmonic-value argument will be wrapped around if greater or less than 16, so you can use this command without worrying about out of range errors.

Example

 (define (animate)
		(colour (vector (gh 1) (gh 2) (gh 3))) ; make a colour from the harmonics, and set it to be the current colour 
		(draw-cube)) ; draw a cube with this colour
 (every-frame (animate))

(ga)

Returns audio-buffer-vector

Returns the current contents of the audio buffer.

Example

 (clear)
 (define p (build-ribbon 128))
 (with-primitive p
    (hint-unlit)
    (pdata-map! (lambda (w) .1) "w"))

 (every-frame
    (let ([a (ga)])
        (with-primitive p
            (pdata-index-map!
                (lambda (i p)
                    (vector (* .25 (- i (/ (pdata-size) 2))) (* 10 (vector-ref a i)) 0))
                "p"))))

(gain gain-number)

Returns void

Sets the gain level for the fft sound, it's 1 by default.

Example

 (gain 100) ; too quiet?!

(process wavfile-string)

Returns void

This command temporarally disables the realtime reading of the input audio stream and reads a wav file instead. For use with the framedump command to process audio offline to make music videos. The advantage of this is that it locks the framerate so the right amount of audio gets read for each frame - making syncing of the frames and audio files possible.

Example

 (process "somemusic.wav") ; read a precorded audio file

(smoothing-bias value-number)

Returns void

A kind of weighted average for the harmonic bands which smooth them out over time. This setting defaults to 1.5. The best value really depends on the quality of the music, and the buffer sizes, and ranges from 0 -> 2. It's more obvious if you give it a try with the bars.scm script

Example

 (smoothing-bias 0) ; no smoothing

(update-audio)

Returns void

Updates the audio subsytem. This function is called for you (per frame) in fluxus-canvas.ss.

Example

 (update-audio)

(set-num-frequency-bins count)

Returns void

Sets the number of frequency bins to use for (gh).

Example

 (set-num-frequency-bins 64)

(get-num-frequency-bins)

Returns count-number

Returns the number of frequency bins used for (gh), or 0 if the audio is not started with (start-audio).

Example

 (get-num-frequency-bins)