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

Add support to generate (on the fly) and load sfxr #14

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

GWRon
Copy link
Contributor

@GWRon GWRon commented Feb 3, 2023

Add support to load .sfxr files or generating it on request via either LoadSfxrSound(preset, seed) or LoadSound() or TSoloudSound.Load() (then via an encoded key: GenerateSfxrUrl(preset:int, seed:Int).

@blitzmax-itspeedway-net brought up the idea of SFXR-support first and made a wonderful and already working repo there:
https://github.com/blitzmax-itspeedway-net/retro.audio

That Repo contains all the samples to try it out. (just replace import retro.audio with Import Audio.AudioSDL for the sake of being)

Yet I think it does not add a further dependency, so would do well right in the audio.mod itself.

@GWRon
Copy link
Contributor Author

GWRon commented Feb 3, 2023

If preferred I could also introduce a new Type:

Type TSoloudSfxrPresetConfig
  Field preset:Int
  Field seed:Int
End Type

And use this instead of packing it in a long and this then in a String.

@GWRon
Copy link
Contributor Author

GWRon commented Feb 3, 2023

taken from scaremongers samples and extended to show simply loading:

' 	SFXR LoadSound( TBank ) Example
'   (c) Copyright Si Dunford, September 2022, All Rights Reserved. 
'   VERSION: 1.1

' This example shows how an SFXR resource file can be loaded from a TBank

SuperStrict

Import Audio.AudioSDL

AppTitle="SFXR LoadSound( TBank ) Example"
Graphics 320, 200

'bank test
'Local bank:TBank = New TBank.Load( "powerup.sfxr" )
'Local sound:TSound = TSoloudSound.Load( bank, SOLOUD_SOUND_SFXR   )
'direct test
Local sound:TSound = LoadSound(GenerateSfxrUrl(8, 22334), SOLOUD_SOUND_SFXR)

Repeat
    Cls
	DrawText( "Press SPACE to play sound", 5, 5 )
    If KeyHit( KEY_SPACE )
        Local channel:TChannel = AllocChannel()
		PlaySound( sound, channel )
    EndIf
    Flip
	Delay( 1 )
Until KeyHit( KEY_ESCAPE ) Or AppTerminate()

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

Successfully merging this pull request may close these issues.

1 participant