SWAG

Module audio

Content

type alias Audio.Type Aliases [src]

BusHandle BusHandle
VoiceHandle VoiceHandle

struct Audio.Bus [src]

Represents a bus.

handle BusHandle

A Voice can be assigned to one or more buses. If you then change some parameters of the bus (like the volume), then all the voices assigned to it will be impacted.

Functions

create Creates an audio bus.
destroy Destroy the bus (immediatly).
getVolume Returns the actual volume.
getVolumeDB Returns the actual volume, in DB.
setVolume Set the playing bus volume between [0..1].
setVolumeDB Set the playing bus volume in DB.

func Bus.create [src]

Creates an audio bus.

func create(numChannels: u32, parent: *Bus = null)->*Bus throw

You can then associate a Voice to that bus with Voice.setRooting Note that you can have a graph of buses, because a bus can have another bus as parent.

func Bus.destroy [src]

Destroy the bus (immediatly).

func destroy(using self) throw

func Bus.getVolume [src]

Returns the actual volume.

func getVolume(using self)->f32 throw

func Bus.getVolumeDB [src]

Returns the actual volume, in DB.

func getVolumeDB(using self)->f32 throw

func Bus.setVolume [src]

Set the playing bus volume between [0..1].

func setVolume(using self, volume: f32, batchID: u32 = 0) throw

func Bus.setVolumeDB [src]

Set the playing bus volume in DB.

func setVolumeDB(using self, volumeDB: f32, batchID: u32 = 0) throw

struct Audio.Codec [src]

Base struct for all codec instances.

srcEncoding SoundFileEncoding The original encoding.
dstEncoding SoundFileEncoding The requested encoding.
type const *Swag.TypeInfoStruct The real type of the codec.

interface Audio.ICodec [src]

Interface to describe a codec.

canEncode func(*ICodec, SoundFileEncoding)->bool
canDecode func(*ICodec, SoundFileEncoding)->bool
init func(*ICodec, ^void, u64)->u64 throw
decode func(*ICodec, ^void, u64, ^void, u64)->{write:u64,read:u64} throw

struct Audio.SoundFile [src]

Represents a sound file.

fullname Core.String
datas Core.Array'(u8) Prefetched datas (in encoding format).
sampleCount u64 Total number of samples.
dataSize u64 Total size, in bytes, of datas.
dataSeek u64 The position in the file where the datas are stored.
encoding SoundFileEncoding Encoding type of the datas.
validity SoundFileValidityMask What informations in this struct are valid.
frequency u32 Sound frequency.
channelCount u32 Number of channels (2 for stereo...).
channelMask u32 Identifier of the channels.
bitsPerSample u32 Number of bits per sample in the datas.
duration f32 Duration, in seconds, of the sound.
validBitsPerSample u16 Number of valid bits per sample (<= bitsPerSample).

The SoundFile is not necessary fully loaded in memory, in case we want it to be streamed.

Functions

load Load a SoundFile from disk.

func SoundFile.load [src]

Load a SoundFile from disk.

func load(fullname: string, loadDatas = true, loadMetaDatas = false)->SoundFile throw

Will load the sound datas if loadDatas is true. Will load the sound metadatas if loadMetaData is true.

enum Audio.SoundFileEncoding [src]

SoundFile internal format.

Unknown
Pcm8 Pcm, uncompressed, 8 bits per sample.
Pcm16 Pcm, uncompressed, 16 bits per sample.
Pcm24 Pcm, uncompressed, 24 bits per sample.
Pcm32 Pcm, uncompressed, 32 bits per sample.
Float32 Pcm, uncompressed, float 32 bits per sample.

enum Audio.SoundFileValidityMask [src]

Determins which informations in the SoundFile struct are valid.

Zero
Format
Frequency
ChannelCount
ChannelMask
BitsPerSample
Duration
SampleCount
ValidBitsPerSample
Data
MetaData

struct Audio.Voice [src]

Represents a playing sound.

Functions

create Creates a new voice for a given sound file.
destroy Destroy the voice.
getVolume Returns the actual volume.
getVolumeDB Returns the actual volume, in DB.
isPlaying Returns true if the voice is currently playing.
pause Pause the playing voice.
play(*SoundFile, VoiceCreateFlags, VoicePlayFlags) Creates a voice and plays it.
play(self, VoicePlayFlags) Plays a voice.
setFrequencyRatio Set the playing pitch.
setRooting Root a voice to a given list of buses.
setVolume Set the playing voice volume between [0..1].
setVolumeDB Set the playing voice volume.
stop Stop the playing voice.

Special Functions

opDrop

func Voice.create [src]

Creates a new voice for a given sound file.

func create(file: *SoundFile, createFlags = VoiceCreateFlags.Default)->*Voice throw

A voice is what will be actually played. You can have as many voices as you want for one unique SoundFile.

func Voice.destroy [src]

Destroy the voice.

func destroy(using self)

func Voice.getVolume [src]

Returns the actual volume.

func getVolume(using self)->f32 throw

func Voice.getVolumeDB [src]

Returns the actual volume, in DB.

func getVolumeDB(using self)->f32 throw

func Voice.isPlaying [src]

Returns true if the voice is currently playing.

func isPlaying(using self)->bool

func Voice.opDrop [src]

func opDrop(using self)

func Voice.pause [src]

Pause the playing voice.

func pause(using self) throw

func Voice.play [src]

Creates a voice and plays it.

func play(file: *SoundFile, createFlags = VoiceCreateFlags.Default, playFlags = VoicePlayFlags.Default)->*Voice throw

By default, the voice will be destroyed when stopped or finished.

Plays a voice.

func play(using self, playFlags = VoicePlayFlags.Zero) throw

By default, you will have to destroy the voice yourself when no more needed, for example if Voice.isPlaying returns false. But if you want the voice to be destroyed automatically when done, set the DestroyOnStop flag in playFlags. See Voice.create

func Voice.setFrequencyRatio [src]

Set the playing pitch.

func setFrequencyRatio(using self, ratio: f32, batchID: u32 = 0) throw

The voice should have been created with VoiceCreateFlags.AcceptPitch. See Voice.create

func Voice.setRooting [src]

Root a voice to a given list of buses.

func setRooting(using self, buses: const [..] *Bus) throw

You can also set buses to null if you want to root the voice only to the main bus (which is the default).

func Voice.setVolume [src]

Set the playing voice volume between [0..1].

func setVolume(using self, volume: f32, batchID: u32 = 0) throw

func Voice.setVolumeDB [src]

Set the playing voice volume.

func setVolumeDB(using self, volumeDB: f32, batchID: u32 = 0) throw

func Voice.stop [src]

Stop the playing voice.

func stop(using self) throw

enum Audio.VoiceCreateFlags [src]

Zero
AcceptPitch
AcceptFilters
Default

enum Audio.VoicePlayFlags [src]

Zero
Loop Play in loops.
DestroyOnStop Destroy the voice once the sound has been played.
Default

enum Audio.VoiceState [src]

Zero
PlayedOnce
Playing
PendingDestroy

namespace Audio.Wav

Functions

loadFile Load a wav file.

func Wav.loadFile [src]

Load a wav file.

func loadFile(using file: *SoundFile, stream: *File.FileStream, loadDatas = true, loadMetaDatas = false) throw

func Audio.addCodec [src]

Register a codec.

func(T) addCodec()

func Audio.convertDBToPercent [src]

Convert a DB value to a percent.

func convertDBToPercent(dbVolume: f32)->f32

func Audio.convertPercentToDB [src]

Convert a percent value to DB.

func convertPercentToDB(percentVolume: f32)->f32

func Audio.createEngine [src]

Creates the audio engine.

func createEngine() throw

Must be called once, before anything else.

func Audio.destroyEngine [src]

Destroy the audio engine.

func destroyEngine()

Must be called at the end, when engine is no more used.

func Audio.getOutputVolume [src]

Get the general output volume.

func getOutputVolume()->f32

func Audio.setOutputVolume [src]

Set the general output volume.

func setOutputVolume(volume: f32) throw
Generated on 08-09-2024 with swag 0.40.0