First time here? Check out the FAQ!
x

Get File Duration from File.

+1 vote
508 views
I would nomally shift click the disk icon and manually copy and paste the file length. (I also like to use the evaluate function to modify the value...)

I decided to look for the expression to automatically do this. Perhaps I am not searching for the right terms. Length? Duration? File? Is this information in the Capytalk Reference?

I did discover the Info > Examples menu! This is splendid and will be very helpful in the future.

Thanks
asked Sep 18, 2017 in Capytalk & Smalltalk by charlienorton (Adept) (2,660 points)

1 Answer

+2 votes
Try this:

'myFileName' fileDuration

When you select that and Ctrl+Y to evaluate, that will give you the file duration in seconds.
answered Sep 18, 2017 by ssc (Savant) (128,000 points)
also useful:
'myFileName' sampleFileDuration
that gives you the file duration using the current samplerate
'myFileName' fileDuration has the advantage that it works with all file types (not just samples files). The duration of a file is not affected by the sample rate (or at least it shouldn't be! If you have an example where this is not working correctly please send it to us via email so we can fix it. Thanks!)
sorry, my bad. I was mixing stuff up. for our NE SPC stuff we needed the original number of samples and there I used 'myFileName' sampleFrames as far as I remember. however, that's not needed usually ;)
...