I'll try to show you how I approach debugging...

The first line:

- Code: Select all
`error: bad argument type - 0.00316228`

Looking through the code, there's only one place in the code that can have come from, and that's dB amplitude value.

Let's check...

In the code we have:

- Code: Select all
`(db-to-linear (* -5 (+ 1 (random 10))))`

so if that is where the first error came from, then "0.00316228" should be equivalent to a dB value that is a multiple of 5, so we can check if it is:

- Code: Select all
`(print (linear-to-db 0.00316228))`

and sure enough, that's -50 dB (prints as -49.999994)

So now we look at the context. Find the first pair of matched parentheses outside of the db-to-linear function:

- Code: Select all
`(mult (db-to-linear (* -5 (+ 1 (random 10)))))`

What are we multiplying "(db-to-linear (* -5 (+ 1 (random 10))))" with? Nothing!

What do we want to multiply "(db-to-linear (* -5 (+ 1 (random 10))))" with?

We want to multiply it with

(osc (hz-to-step 1000) 0.25))

and

(pwlv 0 0.02 1 0.23 1 0.25 0)

so what we should have here is:

- Code: Select all
`(mult (osc (hz-to-step 1000) 0.25))`

(pwlv 0 0.02 1 0.23 1 0.25 0)

(db-to-linear (* -5 (+ 1 (random 10))))

Try changing that, check that the parentheses all match up in pairs, and then see if there are further errors.