ScalaAudioFile is a Scala library to read and write audio files. It is ©opyright 2004-2010 by Hanns Holger Rutz. All rights reserved. ScalaAudioFile is released under the GNU General Public License and comes with absolutely no warranties. To contact the author, send an email to contact at sciss.de
ScalaAudioFile currently compiles against Scala 2.8.0. The repository contains a project file for Intellij IDEA 9 CE, and project files for sbt. Targets for sbt:
clean
compile
doc
package
console
ScalaAudioFile is a refactored version of the Java class de.sciss.io.AudioFile
from ScissLib . It is far from complete and in alpha state. So be warned that this is not production quality and has received little testing!
Currently, only the AIFF and WAVE decoder have been implemented. The writers and the codecs of Wave64, IRCAM, and NeXT still need to be converted.
To open an audio file for reading: AudioFile.openRead( aFile )
or AudioFile.openRead( anInputStream )
. The InputStream
variant has limited functionality, e.g. you cannot seek into the file, but only read sequentially. The stream variant can be used to decode files from an HTTP connection or in-memory (ByteArrayInputStream
).
To the user, frame data is always represented as de-interleaved 32-bit floating point data, so you create a user buffer through Array.ofDim[ Float ]( numChannels, bufFrames )
.
The AudioFile
implementation is currently not thread-safe, but synchronization is planned.
For all further information, please refer to the API docs. They can be created with sbt doc
.
A preliminary test has shown that performance of ScalaAudioFile and ScissLib is practially identical (which is natural since the buffer reader is virtually the same), yielding for a complete read-out of a 6-channels 8 minutes floating point AIFF file (c. 500 MB) approximately 17 seconds. As a comparision, SuperCollider language (with class SoundFile and libsndfile back-end) requires the same amount of time (17 seconds), however without performing de-interleaving. Further tests need to measure the performance of other sample formats (such as int24), as well as writing performance.
The current version can be downloaded from github.com/Sciss/ScalaAudioFile