Page 1 of 5

SpotFX Lib - Retro Sound Generator

Posted: Fri Jan 18, 2008 10:57 pm
by pjay
**** The latest version (including source code) can be found Here ****

------------------------------------------------------------------------------------------------------------

SpotFX is a tiny retro sound generation library that has just a single command:

CreateSpotFX(Random Seed, SoundVolume (0-127), Mutate#,Sound# to catch to)

Download here:
http://homepage.ntlworld.com/phil.james7/PJ_SpotFX.rar

The main sound creation code was converted from DrPetters excellent SFXR utility.

Usage example:

Code: Select all

;/ SpotFX Test app
OpenWindow(1,0,0,194,62,"PB-SpotFX - PJames 08",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
CreateGadgetList(WindowID(1))
ButtonGadget(1,2,2,50,18,"Random") 
StringGadget(2,54,2,70,18,"0",#PB_String_Numeric)
ButtonGadget(3,126,2,16,18,"-")
ButtonGadget(4,144,2,16,18,"+")
ButtonGadget(5,162,2,30,18,"Play")
ButtonGadget(6,2,22,64,18,"Mutate:0")
StringGadget(7,2,42,190,18,"CreateSpotFX(0,0,0.5,1)")
TextGadget(8,70,24,20,18,"Vol:")
ScrollBarGadget(9,92,22,100,17,0,127,1) : SetGadgetState(9,5)

InitSound()

;/ Set initial volume
Sound_Volume.b = 5
;/

;/ generate intro sound
Seed = 9837320 : Update = 1
;/

Repeat
  EventID=WaitWindowEvent()
  Select EventID 
    Case #PB_Event_Gadget
      Select EventGadget()
        Case 1
          RandomSeed(gettickcount_())
          Seed.l =Random(2147483647)
          Mutate = 0 : Update = 1
        Case 2
          If EventType() = #PB_EventType_Change
            Seed = Val(GetGadgetText(2))
            Mutate = 0 : Update = 2
          EndIf
        Case 3
          Seed = Val(GetGadgetText(2))-1
          Mutate = 0 : Update = 1
        Case 4
          Seed = Val(GetGadgetText(2))+1
          Mutate = 0 : Update = 1
        Case 5
          PlaySound(1)
        Case 6
          Mutate+1 : Update=1
        Case 9
          StopSound(1) :  Update = 1
      EndSelect
  EndSelect
  If Update > 0
    Sound_Volume = GetGadgetState(9)
    CreateSpotFX(Seed,Mutate,Sound_Volume,1)
    
    If Update < 2 : SetGadgetText(2,Str(Seed)) : EndIf
    SetGadgetText(6,"Mutate: "+Str(Mutate))
    SetGadgetText(7,"CreateSpotFX("+Str(Seed)+","+Str(Mutate)+","+Str(Sound_Volume)+",1)")
    PlaySound(1)
    Update = 0
  EndIf
Until EventID=#PB_Event_CloseWindow
End

Posted: Fri Jan 18, 2008 11:13 pm
by #NULL
hey! that's great :D

Posted: Sat Jan 19, 2008 12:09 pm
by pjay
It's bad form for changing this so quickly, but I was asked to :D

Update: Have implemented a Mutate function; this applies random variances to the underlying variables that create the waveform.
Changed: Sound volume now takes values 0 - 127, rather than a float.

Have also included a snazzier test application:

Image

Posted: Sat Jan 19, 2008 4:58 pm
by Fluid Byte
The sounds have really nice arcade style.

Very cool, I'm loving it! :mrgreen:

Posted: Sat Jan 19, 2008 6:33 pm
by Rings
love it,great stuff

Posted: Sat Jan 19, 2008 7:08 pm
by milan1612
Really great stuff! Congratulations :)

Posted: Sat Jan 19, 2008 9:12 pm
by tombish
That is realy cool :D , can i use the sounds in my own projects?

Posted: Sat Jan 31, 2009 8:45 pm
by walker
any chance to get this lib for PB4.30?

Posted: Sun Feb 01, 2009 1:50 am
by c4s
walker wrote:any chance to get this lib for PB4.30?
...i would need it too.

Posted: Sun Feb 01, 2009 2:01 pm
by pjay
You can find a compatible version here: http://homepage.ntlworld.com/phil.james7/

I've not had time to test it, but it should be fine.

Posted: Mon Feb 02, 2009 12:50 am
by walker
thanks a lot... :D :D :D
I'll test it

EDIT

Works great.... thanks again :D

Re: SpotFX Lib - Retro Sound Generator

Posted: Thu Dec 03, 2009 6:30 pm
by c4s
Hi there,
PureBasic 4.40 final is now released. Is it possible that you update your great lib?!

It would be even better if you could release your code so we don't have to ask each time. ;)

Re: SpotFX Lib - Retro Sound Generator

Posted: Sun Dec 13, 2009 10:08 pm
by pjay
I'm working away from home at the moment and haven't got the source on me, will try to post next weekend.

Re: SpotFX Lib - Retro Sound Generator

Posted: Mon Dec 14, 2009 8:52 am
by c4s
Good to know that you are still around here.

Thanks in advance!

Re: SpotFX Lib - Retro Sound Generator

Posted: Mon Dec 14, 2009 10:20 am
by Mistrel
My gosh, I love this application. It's so cool. :D

But I see no way to save the sound to a file?

pjay, is there any chance you would mind posting the source for your library? I would be so infinitely useful for retro games.