Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to manipulate raw audio sample data #10

Open
GWRon opened this issue Mar 19, 2021 · 1 comment
Open

How to manipulate raw audio sample data #10

GWRon opened this issue Mar 19, 2021 · 1 comment

Comments

@GWRon
Copy link
Contributor

GWRon commented Mar 19, 2021

As midimaster in the syntaxbomb forum asked on audio manipulation I thought I give it a try with soloud (in Freeaudio I got it working already).

Seems I am missing something -as it does not play anything (it should play "noise"):

SuperStrict
Framework Brl.StandardIO
Import audio.soloud
Import audio.audiominiaudio
Import Brl.GLMax2D
Import Brl.Bank
Import random.xoshiro

'open window
Graphics 800, 600
SetAudioDriver("SoLoud")


'prepare sound data block
Local soundData:TBank = CreateBank(2048)
For local i:int = 0 until soundData.capacity()
	soundData.PokeByte(i, Byte(Rand(255)))
Next

rem
'for now this returns null ... (there is no "LoadSound()" way to retrieve
'an "empty" TSound created by Soloud-drivers
Local sound:TSound = LoadSound(null, SOLOUD_SOUND_WAV | SOUND_LOOP)
'sound._sound = TSLAudioSource
Local slWav:TSLWav = new TSLWav
slWav.loadMem(soundData.Lock(), int(soundData.capacity()), False, False)
TSoloudSound(sound)._sound = slWav
endrem

'rem
Local sound:TSoloudSound = new TSoloudSound
sound.isLooped = True
sound._sound = new TSLWav
TSLWav(sound._sound).loadMem(soundData.Lock(), int(soundData.capacity()), False, False)


PlaySound(sound)


Repeat
	Cls
	
	DrawText("SPACE for random sound data", 0,0)
	Flip
Until KeyHit(KEY_ESCAPE) Or AppTerminate()

Is there a way to obtain the sound samples buffer/byte ptr/mem block so we can fill it with our own data (eg incoming stuff from a midi keyboard or so) ?

@GWRon
Copy link
Contributor Author

GWRon commented Mar 19, 2021

Having Import Brl.Oggloader and replacing/appending

TSLWav(sound._sound).loadMem(soundData.Lock(), int(soundData.capacity()), False, False)

with

sound._sound = sound.TryLoadSound(ReadStream("a valid ogg file.ogg"), SOUND_LOOP)

Plays the music - so the initial setup (audio driver etc) is working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant