tremolo waveforms and logarthmic response of the ear?

Started by jonny, October 07, 2011, 04:58:39 PM

Previous topic - Next topic

jonny

Okay so i'm building a trem with a microcontroller. And I've been building my waveforms and I'm wondering how to do it best. So I think the response of an illumination of an led vs current is relatively linear, the response of the LDR is also restively linear. So my question is how do I take into the account the logarithmic nature of our ear? Do I do something  like invLog(Sin(x))  to get a Sine wave? Or should I just not worry and use a normal sine wave?

nexekho

Are you using the PWM output to light a LED?  I don't know for sure but that might come through in the audio as a sort of ring modulation with the PWM frequency?
I made the transistor angry.

jonny

I'm planning to but if I can't make it go fast enough I'll use a D/A converter.

R.G.

Quote from: jonny on October 07, 2011, 04:58:39 PM
Okay so i'm building a trem with a microcontroller. And I've been building my waveforms and I'm wondering how to do it best. So I think the response of an illumination of an led vs current is relatively linear, the response of the LDR is also restively linear. So my question is how do I take into the account the logarithmic nature of our ear? Do I do something  like invLog(Sin(x))  to get a Sine wave? Or should I just not worry and use a normal sine wave?
Ignore it. You've done the hard part, getting a uC to put out a desired waveform. After that runs, it's all just dinking with numbers in a table.

The problem with precompensating for the human ear is that a small enough section of any curve looks like a straight line. The human ear loudness sense is not only nonlinear to sound pressure level, it's nonlinear with frequencies  (see Fletcher-Munson). And so the right compensation for one frequency is wrong for another, and unless the tremolo always goes from nearly silence to nearly painful at the listener's ear, you are compensating for ever-more-linear subsections of the ear's curve. You can't really compensate unless you know the final volume and frequency (frequencies, I guess) and that's going to be hard to get into the waveform table on a real-time basis.

Use a sine wave, and after the celebratory beverages have worn off, do listening tests with different waveforms and see if there's one your ears like better.

Quote from: nexekho on October 07, 2011, 07:27:42 PM
Are you using the PWM output to light a LED?  I don't know for sure but that might come through in the audio as a sort of ring modulation with the PWM frequency?
It would if LDRs were faster. If he's over about 60Hz, the LDR speed will probably integrate out any PWM modulation. LDRs are slow.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

jonny

Thanks for the info RG.  I think I'll make a few waveforms in mathematica and pick what I like the best.  :icon_biggrin: I'm just about to test the PWM at 500hz hopefully it's fast enough.. we'll see!

R.G.

Quote from: jonny on October 07, 2011, 07:42:36 PM
I'm just about to test the PWM at 500hz hopefully it's fast enough.. we'll see!
500Hz is plenty fast enough. In fact, I suspect you don't even need to use crude R-C filtering on the LED.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

nexekho

What'd be really cool is a very flexible generic LFO for use in this and future projects.  Duty cycle, min/max depth, smoothness, (pow() value on 0 ... 1 triangle wave) flat capping.  Or, if you're willing to go totally overboard like I plan to at Christmas when I have some spare time and cash, build a 10x10 LED matrix and run it off some 4017s/shift registers with visual wave editing!  Is it possible to get pots without a mechanical limit so I can make an educated guess which way/how much it's turning?  Some etch-a-sketch style stuff'd be epic
I made the transistor angry.

R.G.

Quote from: nexekho on October 07, 2011, 07:55:50 PM
Is it possible to get pots without a mechanical limit so I can make an educated guess which way/how much it's turning?  Some etch-a-sketch style stuff'd be epic
encoders

R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

jonny

Okay just testing this now, I have crazy PWM sounds. Perhaps i need to go at 20khz?? I'm using an arduino atmega328. And just doing passive tremolo with my input and output going to one side of the LDR the other going to ground. I can hear the trem underneath the sort of pwm squelching. I think i'm gonna have to use a D/A..

nexekho

ATMegas can clock their PWMs stupidly high, I'm using one through a low pass filter and getting decent audio output.  Which IO pins are you using?  IIRC they run off different timers.
I made the transistor angry.

cpm

more important than logarithmic curves, i think in a tremolo its the duty cycle, or the shape it stays in the "high" side.
I thin kthe EA tremolo is an example of asymetric waveshape, which is often more pleasant than a full sine.

jonny

Quote from: nexekho on October 07, 2011, 08:02:17 PM
ATMegas can clock their PWMs stupidly high, I'm using one through a low pass filter and getting decent audio output.  Which IO pins are you using?  IIRC they run off different timers.
pin 9, it should be running at ~500hz, i'll try doing some filtering before the led and see if it helps..

cpm

Quote from: jonny on October 07, 2011, 08:00:43 PM
Okay just testing this now, I have crazy PWM sounds. Perhaps i need to go at 20khz?? I'm using an arduino atmega328. And just doing passive tremolo with my input and output going to one side of the LDR the other going to ground. I can hear the trem underneath the sort of pwm squelching. I think i'm gonna have to use a D/A..

at least use a resistor to make a divider with the LDR...

the noise is more probably leaking from bad grounding

nexekho

Quote from: jonny on October 07, 2011, 08:07:30 PM
Quote from: nexekho on October 07, 2011, 08:02:17 PM
ATMegas can clock their PWMs stupidly high, I'm using one through a low pass filter and getting decent audio output.  Which IO pins are you using?  IIRC they run off different timers.
pin 9, it should be running at ~500hz, i'll try doing some filtering before the led and see if it helps..

There is a prescaler register you can set to make it tick blistering fast.  I'm doing this from an Arduino with a 328p though which has some initial setup code and a different pinout so it's probably best to find this yourself...
I made the transistor angry.

jonny

Quote from: nexekho on October 07, 2011, 08:45:36 PM
Quote from: jonny on October 07, 2011, 08:07:30 PM
Quote from: nexekho on October 07, 2011, 08:02:17 PM
ATMegas can clock their PWMs stupidly high, I'm using one through a low pass filter and getting decent audio output.  Which IO pins are you using?  IIRC they run off different timers.
pin 9, it should be running at ~500hz, i'll try doing some filtering before the led and see if it helps..

There is a prescaler register you can set to make it tick blistering fast.  I'm doing this from an Arduino with a 328p though which has some initial setup code and a different pinout so it's probably best to find this yourself...

Ah I see that, I found some info on that in the arduiono cookbook. If I set the prescalar to 1 I can get 312500Hz on pin9.. just got to figure out how to do that now haha. I don't want to mess with pins 5 & 6 because it apparently messes with delay times.

jonny

Quote from: cpm on October 07, 2011, 08:08:52 PM

at least use a resistor to make a divider with the LDR...

the noise is more probably leaking from bad grounding

Yip had that in place, it helped but didn't solve the problem. Also tried a low pass filter too.

PRR

> do I take into the account the logarithmic nature of our ear?

Is it?

Twice the Voltage is "twice as loud" for many practical purposes.

Insofar as this assumption holds, then sine-gain is sine-loudness.

Yes, this assumption errs, and particularly for sustained tones over 75db SPL. Music is mostly played over 75db SPL; pianoforte maybe not much over, amplified music usually way over. If your stereo is loud, and you want "twice that loud", when you turn it to 2X voltage in a few seconds your ear tenses-up and it does not sound "twice", you have to turn to 3X Voltage to be "twice", and 3X voltage is 9X Power. (As the hi-fi amp makers love to tell us.)

But this ear-tense is slow. In many musical situations it is steadied by the sound from the rest of the band.

I've limited the example to "twice". In fact from 25db SPL to 75db SPL you can say "10X voltage is ten times louder"; but we don't have any easy penny/dime way to judge "ten times louder" and there are additional non-linearities over large ranges.

But we do not need a large range. If the rest-of-band is cruising 100db SPL, and your guitar is wobbling 105db-90db, you will stand-out on the peaks and vanish in the dips. (Even without a band, at typical tremolo rates in rooms large/live enough to be musically interesting, your own average room-reverb sets an average for your wobbles to stand-out / dip-under.)

Note that we do not need "silence". The gain does not "have" to drop to zero. Certainly if it drops 30db it will "vanish". 12db drop may be "deep enough" for most musical forms.

"Twice as loud" is not very absolute. I know an excellent musician who refused to accept it as a useful measure. Others had to hear 1.5X or 3X to say "twice". A 1.1X change is barely audible on pure tone. A 1.2X change is hard to hear in speech/music signal. We really have poor judgement of fine level changes.

Why do we use "sine"??

The VERY original tremolo is a rank of organ pipes in a box with doors worked by the player's spare foot. Such a box can't be sealed yet open quickly, the depth is probably no more than 12db and that's plenty. Organists have other things for their feet to work, so the common effect was mechanized with a motor and crank, which naturally gives a quasi-sine.

Near-sine oscillators can be built with one active device, and that used to be a consideration (OTOH you are using 50,000 active devices).

A sine has no annoying "blips" or "tips" or "flat-tops". It's always moving but nothing stands-out except the overall wobble.

Our trem sines are not far below the audio band. Any overtone on the trem tend to be audible as "pitch" not "volume". An 8Hz trem with a strong 10th harmonic would give a constant 80Hz buzz (probably an 80 88 96 104...Hz buzz).

Symmetry is important (as cpm says). Is it mostly-more, mostly-less, or evenly more/less? If "mostly less" then average volume tends to drop, and that's normally not-wanted. If strongly mostly-more, then it is just "more" with a hiccup, not always a flattering sound but sometimes good flavor.

You want a "fairly smooth balanced" waveform.

Fussing with higher math seems to me to be a distraction. The ear is not a precision curve-follower. But WTH, lookup tables are easier than carving cams for door-motors.

> I have crazy PWM sounds

It's leaking somehow. Low-pass the feed to the LED at 10Hz. Watch grounding: 5V square-waves leaking 1% into audio is nearly as big as guitar signal. At high impedance you also need to keep audio shielded from all other signals.
  • SUPPORTER