The Alternative Csound Reference Manual
Previous |  | Next

# filelen

filelen -- Returns the length of a sound file.

## Description

Returns the length of a sound file.

## Syntax

ir filelen ifilcod

## Initialization

ifilcod -- sound file to be queried

## Performance

filelen returns the length of the sound file ifilcod in seconds.

## Examples

Here is an example of the filelen opcode. It uses the files filelen.orc, filelen.sco, and mary.wav.

Example 1. Example of the filelen opcode.

    /* filelen.orc */
    ; Initialize the global variables.
    sr = 44100
    kr = 4410
    ksmps = 10
    nchnls = 1

    ; Instrument #1.
    instr 1
      ; Print out the length of the audio file
      ; "mary.wav" in seconds.
      ilen  filelen "mary.wav"
      print ilen
    endin
    /* filelen.orc */

    /* filelen.sco */
    ; Play Instrument #1 for 1 second.
    i 1 0 1
    e
    /* filelen.sco */

The audio file "mary.wav" is 3.5 seconds long. So filelen's output should include a line like this:

    instr 1:  ilen = 3.501

## See Also

filenchnls, filepeak, filesr

## Credits

Author: Matt Ingalls
July 1999

Example written by Kevin Conder.

New in Csound version 3.57

Previous | Home | Next
expsegr | Up | filenchnls