Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

Sound / Synthesizer Problem Please Help!!

edited May 5 in Questions Posts: 31

Hello, I want to make a synthesizer with a line y = ( math.sin(x / 100) * 100 ) and play the sound y = freq
But i dont know how
Can someone Help?
Thank you.

Comments

  • dave1707dave1707 Mod
    Posts: 7,523

    @Silvio2400 This isn't exactly what you want, but it might get you started. See the sound command in the reference for more info.

    function setup()
        x=0
        z=100
    end
    
    function draw()
        background(40, 40, 50)
        z=z+1
        if z>30 then
            x=x+1
            y=math.sin(math.rad(x))
            print("y= "..y)
            s()
            z=0
        end
    end
    
    function s()
        instrument = {StartFrequency = y, DecayTime = 1}
        sound(instrument)
    end
    
  • Posts: 31

    @dave1707 Thank you for the example it will get me started but whats the odd delay after y 0.5? Is it a sound bug?

  • dave1707dave1707 Mod
    Posts: 7,523

    @Silvio2400 I noticed those delays also. I don't know the reason, but I doubt it's a sound bug. I didn't have time to figure it out when I created the example.

  • dave1707dave1707 Mod
    Posts: 7,523

    @Silvio2400 The sound function shouldn't be called constantly like I'm doing in the draw function. When called, the sound function should be allowed to finish what it's doing before it's called again.

Sign In or Register to comment.