HolyLib Wiki

IGModAudioChannel:WriteToDisk

 boolean, string IGModAudioChannel:WriteToDisk( string fileName, number bassFlags, function callback, boolean async = false )

Description

Writes the channel into a file always using the DATA gamePath, the encoder internally used depends on the filename.
Valid encoders for file extension are:

  • .wav (Requires BASSENC plugin)
  • .aiff (Requires BASSENC plugin)
  • .mp3 (Requires BASSENC_MP3 plugin)
  • .ogg (Requires BASSENC_OGG plugin)
  • .opus (Requires BASSENC_OPUS plugin)
  • .flac (Requires BASSENC_FLAC plugin)

    This function requires the BASSENC plugin to work at all!
    You can find all the plugins at https://www.un4seen.com/ drop them into the bin/ folder besides libbass.so

    This function only works on decode channels, a channel needs to have decode set as a flag when being created

    Recently Added

    This was recently added in version (0.8 - DEV).

Arguments

1string fileName
2number bassFlags
3function callback

Function argument(s):
1boolean success -
2string errMsg -
Function return argument(s):

4boolean async = false

Returns

1boolean success
2string errMsg = nil

Example

Example usage of having a .wav and making it a .mp3

bass.PlayFile("data/exampleSong.wav", "decode", function(channel, a, b) g_Channel = channel -- Prevent gc from hitting while were processing it local flags = bit.bor(0x40000, 0x20000) -- BASS_ENCODE_AUTOFREE | BASS_ENCODE_PCM print("Did the job manage to start?", channel:EncodeToDisk("exampleSong.mp3", flags, function(success, errMsg) print("Did it work?", success, errMsg)
end, true)) end)