GEN49
Prev | Score Statements and GEN Routines | Next

## GEN49

GEN49 — Transfers data from an MP3 soundfile into a function table.

## Description

This subroutine transfers data from an MP3 soundfile into a function table.

## Syntax

    f#  time  size  49  filcod  skiptime  format

## Performance

size -- number of points in the table. Ordinarily a power of 2 or a power-of-2 plus 1 (see f statement); the maximum tablesize is 16777216 (224) points. The allocation of table memory can be deferred by setting this parameter to 0; the size allocated is then the number of points in the file (probably not a power-of-2), and the table is not usable by normal oscillators, but it is usable by a loscil unit. The soundfile can also be mono or stereo.

filcod -- integer or character-string denoting the source soundfile name. An integer denotes the file soundin.filcod ; a character-string (in double quotes, spaces permitted) gives the filename itself, optionally a full pathname. If not a full path, the file is sought first in the current directory, then in that given by the environment variable SSDIR (if defined) then by SFDIR. See also soundin.

skiptime -- begin reading at skiptime seconds into the file.

format -- specifies the audio data-file format required:

1 - Mono file 3 - First channel (left)
2 - Stereo file 4 - Second channel (right)

If format = 0 the sample format is taken from the soundfile header.

| Note
Reading stops at end-of-file or when the table is full. Table locations not filled will contain zeros. If p4 is positive, the table will be post-normalized (rescaled to a maximum absolute value of 1 after generation). A negative p4 will cause rescaling to be skipped.

## Examples

Here is an example of the GEN49 routine. It uses the files gen49.csd.

Example 1311. An example of the GEN49 routine.

    <CsoundSynthesizer>
    <CsOptions>
    ; Select audio/midi flags here according to platform
    -odac      ;;;realtime audio out
    ;-iadc    ;;;uncomment -iadc if realtime audio input is needed too
    ; For Non-realtime ouput leave only the line below:
    ; -o gen49.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

    sr = 44100
    ksmps = 32
    nchnls = 2
    0dbfs  = 1

    instr 1

    kcps = sr/ftlen(1)
    asig oscil .8, kcps, 1
       outs asig, asig

    endin
    </CsInstruments>
    <CsScore>
    f 1 0 131072 49 "beats.mp3" 0 1	;read an audio file (using GEN49).

    i 1 0 2
    e
    </CsScore>
    </CsoundSynthesizer>

This is the diagram of the waveforms of the GEN49 routine, as used in the example:

f 1 0 131072 49 "beats.mp3" 0 1

## Credits

Written by John ffitch

February 2009.

Prev | Up | Next
GEN44 | Home | GEN51