PBSpotFX_Demivec v1.5

Advanced game related topics
User avatar
Demivec
Addict
Addict
Posts: 4260
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

PBSpotFX_Demivec v1.5

Post by Demivec »

This is a program that is more or less a direct conversion of 'sfxr' written my Tomas Pettersson (DrPetter).

It differs from the version implemented by pjay found here and so I thought I would put it in its own thread to avoid confusion.

pjay's works great but I was interested in the original program's ability to control the sound being generated as well as having certain sound types that could be generated more quickly with only a single button push. That's why I produced this version (in 3/9/2009).

I was delayed a little as I worked on a custom sliderGadget to use for input. I learned a great deal in the process and will post that soon in the Tips and Tricks forum. It works well for this utility though admittedly things could have no doubt been done in a simpler way. :wink:

The last feature I wanted to add was a visual display for the sound being generated. I finally finished the details on that. It doesn't compare to pjay's but it works and that will have to do for the moment.

The file requires PureBasic v4.40 (though not by much). All source is included. It requires windows because of my custom sliderGadget and has only been tested with 32-bit x86.

I hope you find it useful. Simply compile the code and start off by pushing some buttons.

Image

The file can be found here.

@Edit: updated broken links
Last edited by Demivec on Tue Jun 03, 2025 3:15 pm, edited 3 times in total.
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: PBSpotFX_Demivec v1.5

Post by c4s »

This looks really great!

But at first I missed a clear structure that enables me to generate my sounds. A procedure with an sound settings structure as a parameter or so.
Tomorrow I will take a deeper look at it because maybe I have missed it in this short time. ;)
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
User avatar
Demivec
Addict
Addict
Posts: 4260
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: PBSpotFX_Demivec v1.5

Post by Demivec »

c4s wrote:This looks really great!

But at first I missed a clear structure that enables me to generate my sounds. A procedure with an sound settings structure as a parameter or so.
Tomorrow I will take a deeper look at it because maybe I have missed it in this short time. ;)
Do you mean you would like to generate the sounds by specifying their parameters? That is something that is not implemented with this utility but I think could easily be done. That would allow you to generate sounds for use in a program instead of including them as binaries or otherwise, thus saving a few megabytes of storage for each one. It deserves to be looked into a little more.

This utility simply generates the sounds randomly or from settings and then allows them to be exported to a wav file.
Mistrel
Addict
Addict
Posts: 3415
Joined: Sat Jun 30, 2007 8:04 pm

Re: PBSpotFX_Demivec v1.5

Post by Mistrel »

I don't see any of your custom sliders being drawn and the jiggling-line-display (the thing with the black background) doesn't animate.

I'm using Windows 7 x64 and compiling with PB 4.40 x86.
User avatar
Rings
Moderator
Moderator
Posts: 1435
Joined: Sat Apr 26, 2003 1:11 am

Re: PBSpotFX_Demivec v1.5

Post by Rings »

great stuff......thx a lot
SPAMINATOR NR.1
User avatar
flaith
Enthusiast
Enthusiast
Posts: 704
Joined: Mon Apr 25, 2005 9:28 pm
Location: $300:20 58 FC 60 - Rennes
Contact:

Re: PBSpotFX_Demivec v1.5

Post by flaith »

My wish comes true :shock:
Thanks a lot Demivec :D
“Fear is a reaction. Courage is a decision.” - WC
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: PBSpotFX_Demivec v1.5

Post by c4s »

Demivec wrote:Do you mean you would like to generate the sounds by specifying their parameters? That is something that is not implemented with this utility but I think could easily be done. That would allow you to generate sounds for use in a program instead of including them as binaries or otherwise, thus saving a few megabytes of storage for each one. It deserves to be looked into a little more.

This utility simply generates the sounds randomly or from settings and then allows them to be exported to a wav file.
I would like to use it just like SpotFX from pjay. What I like on your porting is that I'm able to set up every parameter instead of hitting "random" all the time to explore new sounds.

So I don't get the structure of the sound generation code very well.
What procedures do I need for only generating a sound? And is it possible to use it like a normal PureBasic sound or do I have to generate it each time?
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Re: PBSpotFX_Demivec v1.5

Post by rsts »

Mistrel wrote:I don't see any of your custom sliders being drawn and the jiggling-line-display (the thing with the black background) doesn't animate.

I'm using Windows 7 x64 and compiling with PB 4.40 x86.
Same config and works fine here.

All I can say is WOW :shock:

cheers
User avatar
Demivec
Addict
Addict
Posts: 4260
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: PBSpotFX_Demivec v1.5

Post by Demivec »

I corrected a very small fault in the program dealing with the animated sound display. The corrected version is available for download under the same name and from the same link in the first post.

If you would rather simply make the change yourself instead of re-downloading it. Here's the info:

Code: Select all

;file " PBSpotFX (Demivec) v15.pb"
;change line 675 from
iWidth = ImageWidth(expImage) - 1
;to
iWidth = ImageWidth(expImage)
@Mistrel: The sliders and animated sound display use ImageGadgets. In addition the sound display is drawn to only with PB's 2D_Drawing Library. With that in mind I cannot determine what may be preventing the display of those things.

c4s wrote:What procedures do I need for only generating a sound? And is it possible to use it like a normal PureBasic sound or do I have to generate it each time?
@c4s: The sound is generated by setting parameters in the structure 's.soundsettings' (sliders) and uses the work structure 'p.playsettings'. The sound is produced in PB by creating a wave file in memory using procedure CreateSpotFXWAV(). This in turn calls the procedure SynthSample() repetively until the wav's sound data is completed.

You can use it like a normal PureBasic sound by using CatchSound() to convert the wav file from the memory buffer. I would like to make this a little easier to do, possibly including a trimming ability to select only a portion of a sound from what was generated. There's no need to wait for me you can take what is available and adjust it to suit your needs. :wink: As I stated this would allow a sound to be used by creating it during runtime and thus keep a file's size very low.


@Rings, flaith, rsts, & others: I am happy to see that this has been well received. :D
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: PBSpotFX_Demivec v1.5

Post by c4s »

Thanks Demivec for the short explanation of (obvious?) your code - It's well done!

One thing about the SliderGadget: When I click on one it is selected (like buttons are). In my opinion this selection line is really confusing but except of this it's great too ;)
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
User avatar
Demivec
Addict
Addict
Posts: 4260
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: PBSpotFX_Demivec v1.5

Post by Demivec »

c4s wrote:One thing about the SliderGadget: When I click on one it is selected (like buttons are). In my opinion this selection line is really confusing but except of this it's great too ;)
I agree that the selection line can be confusing.

It indicates that you can interact with the slider by using the keyboard also. I considered several ways of indicating that the SliderGadget had keyboard focus and this was the simplest and least intrusive. The SliderGadget responds to the Home, End, Delete, Tab, and directional keys. It can also sport a variety of borders and colors, be made vertical or horizontal and can have the way it responds to directional keys flipped in addition to visually being flipped (like drawing it right-to-left instead of left-to-right).

I shouldn't say too much about it yet (oops, too late :D ). I'm going to post those details later in their own thread. :wink:
User avatar
Rook Zimbabwe
Addict
Addict
Posts: 4322
Joined: Tue Jan 02, 2007 8:16 pm
Location: Cypress TX
Contact:

Re: PBSpotFX_Demivec v1.5

Post by Rook Zimbabwe »

FAN-Frooping-TASTIC!!!! Great work Jared! 8)

I just wish I could somehow set loop length internally! and notes random lngth of time each!

Still playing with it though maybe you can
Binarily speaking... it takes 10 to Tango!!!

Image
http://www.bluemesapc.com/
User avatar
idle
Always Here
Always Here
Posts: 5836
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: PBSpotFX_Demivec v1.5

Post by idle »

great
User avatar
luis
Addict
Addict
Posts: 3893
Joined: Wed Aug 31, 2005 11:09 pm
Location: Italy

Re: PBSpotFX_Demivec v1.5

Post by luis »

Interesting, I saw this technique used in some programs before and thinked about implementing something similar a day or another... thank you for sharing it. :)
"Have you tried turning it off and on again ?"
A little PureBasic review
User avatar
Blue Steel
Enthusiast
Enthusiast
Posts: 132
Joined: Wed Aug 31, 2005 4:49 pm
Contact:

Re: PBSpotFX_Demivec v1.5

Post by Blue Steel »

I'm in the process of editing your code in order to be able to make into something similar to PJ's code where you can enter the values from a procedure call so that it can make sounds live from within a program.

It will eventually be split into 2 programs.. first one similar to this that can also display the call and values needed to generate the wave .. the other to be a procedure to play it in your program.

the difference i'm hoping to achieve is that instead of in PJ's case where they put in a random seed .. that you'll be able to use your export and use your .sfs data into end program or by adding that data to a procedure call

thus making it a similar command to those of the retro languages.

in doing so i've noticed that when you press random that at least some of the sliders that you have set up for only posative adjustments are at times displaying Negative values.

is this correct.. or are they actually or should they be converted to Posatives or ignored(IE: set to 0) when creating/playing the sound

eg: attacktime , decay time , vibrato depth

I hope you can follow what i'm attempting to do. (yeah i know i'm jumping in at the deep end again)
any help in this project of mine would greatfully be accepted


you can d/load a copy of my edited file from here
http://www.codingmonkeys.com/index.php? ... dl=item272

remember its still a work in progress and things WILL DEFINATLY change

changes so far .
Displays Values of the settings beside the sliders
added use of consolas ( size 8 ) font
touched up layout of screen
added SELECT/COPY/PASTE box (hopefully to be used later.. already generating sample syntax with correct values.. order of which WILL change)
made displayed waveform on play larger

Comments and Edits (to tidy up my code) appreciated
Last edited by Blue Steel on Sun May 02, 2010 11:54 am, edited 2 times in total.
Currently using PureBasic 4.51(x86)

Image http://www.codingmonkeys.com
Covers many languages including PureBasic
Post Reply