Page 1 of 2
PBSpotFX_Demivec v1.5
Posted: Tue Dec 15, 2009 8:33 pm
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.
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.
The file can be found
here.
@Edit: updated broken links
Re: PBSpotFX_Demivec v1.5
Posted: Wed Dec 16, 2009 12:01 am
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.

Re: PBSpotFX_Demivec v1.5
Posted: Wed Dec 16, 2009 12:07 am
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.
Re: PBSpotFX_Demivec v1.5
Posted: Wed Dec 16, 2009 7:24 am
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.
Re: PBSpotFX_Demivec v1.5
Posted: Wed Dec 16, 2009 9:18 am
by Rings
great stuff......thx a lot
Re: PBSpotFX_Demivec v1.5
Posted: Wed Dec 16, 2009 12:24 pm
by flaith
My wish comes true
Thanks a lot Demivec

Re: PBSpotFX_Demivec v1.5
Posted: Wed Dec 16, 2009 2:07 pm
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?
Re: PBSpotFX_Demivec v1.5
Posted: Wed Dec 16, 2009 3:29 pm
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
cheers
Re: PBSpotFX_Demivec v1.5
Posted: Wed Dec 16, 2009 5:13 pm
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.

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.

Re: PBSpotFX_Demivec v1.5
Posted: Wed Dec 16, 2009 7:54 pm
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

Re: PBSpotFX_Demivec v1.5
Posted: Wed Dec 16, 2009 8:56 pm
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

). I'm going to post those details later in their own thread.

Re: PBSpotFX_Demivec v1.5
Posted: Wed Dec 16, 2009 9:44 pm
by Rook Zimbabwe
FAN-Frooping-TASTIC!!!! Great work Jared!
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
Re: PBSpotFX_Demivec v1.5
Posted: Thu Dec 17, 2009 8:25 pm
by idle
great
Re: PBSpotFX_Demivec v1.5
Posted: Thu Dec 17, 2009 9:13 pm
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.

Re: PBSpotFX_Demivec v1.5
Posted: Fri Apr 30, 2010 2:47 am
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