SpotFX Lib - Retro Sound Generator

Advanced game related topics
pjay
Enthusiast
Enthusiast
Posts: 163
Joined: Thu Mar 30, 2006 11:14 am

SpotFX Lib - Retro Sound Generator

Post 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
Last edited by pjay on Wed Aug 11, 2010 1:28 pm, edited 3 times in total.
#NULL
Addict
Addict
Posts: 1440
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Post by #NULL »

hey! that's great :D
pjay
Enthusiast
Enthusiast
Posts: 163
Joined: Thu Mar 30, 2006 11:14 am

Post 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
User avatar
Fluid Byte
Addict
Addict
Posts: 2336
Joined: Fri Jul 21, 2006 4:41 am
Location: Berlin, Germany

Post by Fluid Byte »

The sounds have really nice arcade style.

Very cool, I'm loving it! :mrgreen:
Last edited by Fluid Byte on Thu Jan 21, 2010 3:02 pm, edited 1 time in total.
Windows 10 Pro, 64-Bit / Whose Hoff is it anyway?
User avatar
Rings
Moderator
Moderator
Posts: 1427
Joined: Sat Apr 26, 2003 1:11 am

Post by Rings »

love it,great stuff
SPAMINATOR NR.1
milan1612
Addict
Addict
Posts: 894
Joined: Thu Apr 05, 2007 12:15 am
Location: Nuremberg, Germany
Contact:

Post by milan1612 »

Really great stuff! Congratulations :)
Windows 7 & PureBasic 4.4
tombish
New User
New User
Posts: 2
Joined: Fri Jan 18, 2008 3:48 am
Location: Devon, UK

Post by tombish »

That is realy cool :D , can i use the sounds in my own projects?
walker
Enthusiast
Enthusiast
Posts: 634
Joined: Wed May 05, 2004 4:04 pm
Location: Germany

Post by walker »

any chance to get this lib for PB4.30?
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Post by c4s »

walker wrote:any chance to get this lib for PB4.30?
...i would need it too.
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
pjay
Enthusiast
Enthusiast
Posts: 163
Joined: Thu Mar 30, 2006 11:14 am

Post 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.
walker
Enthusiast
Enthusiast
Posts: 634
Joined: Wed May 05, 2004 4:04 pm
Location: Germany

Post by walker »

thanks a lot... :D :D :D
I'll test it

EDIT

Works great.... thanks again :D
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: SpotFX Lib - Retro Sound Generator

Post 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. ;)
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
pjay
Enthusiast
Enthusiast
Posts: 163
Joined: Thu Mar 30, 2006 11:14 am

Re: SpotFX Lib - Retro Sound Generator

Post 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.
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: SpotFX Lib - Retro Sound Generator

Post by c4s »

Good to know that you are still around here.

Thanks in advance!
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Re: SpotFX Lib - Retro Sound Generator

Post 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.
Post Reply