Whistle sound... Solved!

Hi there! I want to use a whistle sound (like in a sports competition) in a game i am working on, but after 200 trial & errors on the sound tool, i give up! Can anybody help me? Thanks!

Please… Can anyone help me? I don’t understand how to use the sound parameter to make a whistle sound, although some sounds are close to it, so it is clear it is possible. Or do you know a link that explains how each setting works? @dave1707 @Zoyt @Andrew_Stacey thanks in advance.

Sorry, don’t know much about the sound here. You need @Fred for that.


I haven’t played around with sound very much, but maybe this might give you a start. Look at the sound documentation and try adding different parameters in the sound function. I have 3 of them here, but maybe other combinations will give you a better result.

function setup()

function draw()
    background(40, 40, 50)
    text("tap screen for sound",WIDTH/2,HEIGHT/2)
    if s then

function touched(t)
    if t.state==BEGAN then

Thank you for your help you both. dave I have tried your program but cannot get a whistle. I have read the doc and doesnt really help. I have tried many radom trials and some are close but not quite. Still trying. Thank you.

Hi @Jmv38, here is a whistleish kind of sound I whipped up:

sound({StartFrequency = 0.730444, AttackTime = 0, SustainTime = 0.485449, SustainPunch = 0.553973, DecayTime = 0.203096, MinimumFrequency = 0, Slide = 0.5, DeltaSlide = 0.5, VibratoDepth = 0.577503, VibratoSpeed = 0.848091, ChangeAmount = 0.502993, ChangeSpeed = 0.687306, SquareDuty = 0.5, DutySweep = 0.5, RepeatSpeed = 0.5, PhaserSweep = 0.5, LowPassFilterCutoff = 1, LowPassFilterCutoffSweep = 0.5, LowPassFilterResonance = 0.5, HighPassFilterCutoff = 0.5, HighPassFilterCutoffSweep = 0.598142, Waveform = 0, Volume = 1})

I used the advanced sound parameters, which you can access either from tapping the red sound() function or programmatically. There is a program I used to play around with the sounds with more precision, which I’ll link to a moment.

Here is a link to the thread where you can find Sound Slider, by @Herwig and I:


@Fred thank you very much. You sound example is actually close to a whistle. I am going to try and make it higher frequency and play on the attack/decay. I’ll be back. Also: i have created the project from your code: there is a sound but the sliders don’t show up… I have ipad1 and last version of Codea. Don’t know what’s going on. Thanks a lot!

Well thanks to your expample I made it!

local whistle = {StartFrequency= 1, AttackTime = 0, SustainTime = 0.25, SustainPunch = 0.6, DecayTime = 0, MinimumFrequency = 0, Slide = 0.5, DeltaSlide = 0.5, VibratoDepth = 0.6, VibratoSpeed = 0.9, ChangeAmount=0.6, ChangeSpeed = 0.7, SquareDuty = 0.5, DutySweep = 0.5, RepeatSpeed = 0.5, PhaserSweep = 0.5, LowPassFilterCutoff = 1, LowPassFilterCutoffSweep = 0.5, LowPassFilterResonance = 0.5, HighPassFilterCutoff = 0.5, HighPassFilterCutoffSweep = 0.6, Waveform = 0, Volume = 1}

thank you very much @Fred @Andrew_Stacey @dave1707

You’re welcome @Jmv38, I like the whistle sound you made. I wonder why you could not run the Sound Slider program, did you use the latest code in the thread? What orientation did you start with?

Hi @Fred, do you know some good tutorial, ebook, book, reference or whatever about sounds / waveforms? I’m totally ignorant about this topic but very interested and I’d like to better understand the theory behind but I don’t know where to start! The target I’d like to reach is to be able to set a meaningfull configuration if I want to pruduce a specific sound, without finding myself to just try random slider configuration (obviously without good results…).

Hi @shrike, I’m sorry to say I seem to have picked this up by osmosis! I had a look at this wiki page though, and it has some relevant bits, eg vibrato etc: http://en.wikipedia.org/wiki/Timbre

I also need to read up on generating waveform data.

The thing to bear in mind with the integrated sfxr part of Codea is that that bit was written separately and very quickly to generate sound effects for games. If you want to use sfxr, then there is info on the net, and several other implementations. I’ve even got sfxr for iPhone. But it can’t recreate every type of sound. You get the basic waveforms that were used in early computer music, sine, square and saw, plus white noise.

It is also possible to manually generate complex waveform data, but that sounds tricky to me.

I would recommend trying Sound Slider or the Advanced sound picker and trying to isolate different effects. Sometimes there are pairs of sliders that work together, so keep that in mind. Let me know if you have any specific questions and I’ll try to help.

Hello, sorry I didn’t get around to answering you earlier. My top suggestion is using the SFXR sound that you/@Fred came up with.
The other option that you’ll have to wait for is using @frosty’s sound player, that has been apparentally in developement. That way you can play any premade sound, as far as I can tell. Just search for that discussion every once in a while, and hopefully, it will be released.
I hope that helps! (Sorry for any gramarical errors. I’m on an iPhone.)