Platforms to show: All Mac Windows Linux Cross-Platform

SoundFileMBS class

Type Topic Plugin Version macOS Windows Linux iOS Targets
class Audio MBS Tools Plugin 17.4 ✅ Yes ✅ Yes ✅ Yes ✅ Yes All
A cross platform class to use sndfile library to read/write audio samples.
Example
// load the sndfile library and show the format of an audio file
Var libFile As FolderItem
#If TargetMacOS Then
libFile = SpecialFolder.Desktop.Child("libsndfile.dylib")
#ElseIf TargetWindows Then
libFile = SpecialFolder.Desktop.Child("sndfile.dll")
#Else
libFile = SpecialFolder.Desktop.Child("libsndfile.so")
#EndIf

If Not SoundFileMBS.LoadLibrary(libFile) Then
MessageBox "Failed to load library: " + SoundFileMBS.LoadErrorMessage
Return
End If

Var file As FolderItem = SpecialFolder.Desktop.Child("test.wav")
Var sound As SoundFileMBS = SoundFileMBS.Open(file)

If sound = Nil Then
MessageBox "Failed to open audio file."
Return
End If

Var info As SoundFileInfoMBS = sound.Info
MessageBox info.Channels.ToString + " channels, " + info.SampleRate.ToString + " Hz, " + info.Frames.ToString + " frames"
sound.Close

As sndfile library is LGPL, you need to include library within your app folder and load it at runtime.
This is an abstract class. You can't create an instance, but you can get one from various plugin functions.

Seek Mode

Constant Value Description
kSeekCurrent 1 Seek relative to current position.
kSeekEnd 2 Seek relative to end.
kSeekSet 0 Seek relative to begin.

Strings

Constant Value Description
kStringAlbum 7 Album
kStringArtist 4 Artist
kStringComment 5 Comment
kStringCopyright 2 Copyright
kStringDate 6 Date
kStringGenre 10 Genre
kStringLicense 8 License
kStringSoftware 3 Software
kStringTitle 1 Title
kStringTrackNumber 9 Track Number.

This class has no subclasses.

Blog Entries

Videos

Release notes

  • Version 17.4
    • Added sndfile plugin part with new SoundFileMBS class to read/write audio samples.

Some examples using this class:

Some related classes:


The items on this page are in the following plugins: MBS Tools Plugin.


SoundFileInfoMBS   -   SpamSumMBS


The biggest plugin in space...