Csound Csound-dev Csound-tekno Search About

RE: Audio file lengths

Date1999-07-09 19:15
FromDavid Boothe
SubjectRE: Audio file lengths
RE: Audio file lengths

1. Use a GEN01 table with power-of-two (+1 if you want), that you know is larger than the file. This will take some experimentation if you have no way of knowing that externally (such as Cool Edit or equivalent).

2. Use nsamp to measure the length of the soundfile. nsamp should not count empty table points after the  end of the sound file.

3. Divide the number returned by nsamp with the original sample rate of the file to get the original length.

-David.

> -----Original Message-----
> From: richard bowers [mailto:richardbowers@simulacrum.freeserve.co.uk]
> Sent: Friday, July 09, 1999 3:45 AM
> To: csound csound
> Subject: Audio file lengths
>
>
> Can anyone offer me a solution to obtaining the duration (if
> possible) or
> file size of an audio file stored on disk from within a
> instrument? I feel
> it would be useful to know the duration of a file to make
> better use of -
> and prevent errors when using - the skiptime on the
> soundin/diskin ugs.
>
> Thanks,
> Richard Bowers.
>


Date1999-07-10 03:08
From"Matt J. Ingalls"
SubjectRE: Audio file lengths
> 1. Use a GEN01 table with power-of-two (+1 if you want), that you know is
> 2. Use nsamp to measure the length of the soundfile. nsamp should not count

this is great except for huge files you dont want to load them into a
table.

what i usually do is label the sound files "the old fashioned way"
(geez-ive been so nostalgic lately...)
soundin.x

then i look up their durations in sndinfo - then i put them in a GEN02
list (in order of their soundin names)

with this you can specify the soundin.x file from the score ('x' in a
pfield) and inside the orc you can do a table lookup on the GEN2 index to
'x' to pull out the right duration.

with all the new string capabilities, tables, and macros added the past
year or so, i bet there is a way you could do something similiar but use
the actual soundfile name rather than renaming everything to soundin.x..

-matt