Keyboard not in tune

Mmm caffeine.

A good source of power and connections with shoes makes a difference in the audio.

Since we are also dealing with analog it’s not perfect like a digital signal. Unlike analog which is effected by a lot of different variables including real world variables we have no control over. We are tuning with digital devices which allows us to see and hear the frequency. We can fine tune the signals using our phones. 100 years ago it was a pair of ears and a tuning fork.

Try to fine tune with a guitar tuner to a close enough approximation and then close your eyes to finish the tuning. This is where creativity comes into play.

This looks like a limitation in the occilator but we only have so much control over analog inputs and outputs. That’s why analog creates character or a unique timber. This is the strength of analog because our bits will never have exactly the same because timber. Like most analog instruments

Think about it.

Why don’t all guitar brands sound exactly the same?

Why does my monotron have to warm up longer in Colorado than in Texas?

Why doesn’t my Korg filter sound exactly the same as my moog filter?

Why does a record sound warm and CD quality perfect?

How many licks does it take to get to the tootsie roll center of a tootsie pop?

If you want absolute perfect go digital. Digital Software sounds the same on all PCs. Analog is not perfect just like people… unique.

2 Likes

Yo @sc4r4b!

I am also active on a photography forum which has a large contingent of film photographers, and the discussions sound very similar to this.

No surprise Chris! The two artistic mediums of light and sound are intertwined by the same physics.

Do you use an analog or digital camera? Film or memory card? :stuck_out_tongue_winking_eye:

I’m actually a professional product photographer. Except I’m so digital that my job title is 3D artist. See what I did there?

Hey scarab, I’ve used both digital and ana… film. (It’s not analog, it’s film, which deals with discrete particles of silver, not an infinitely variable silver density.)

Everyone realizes that digital has better resolution than film, it has better range, and you can edit it much easier to a much greater extent. On the other hand film offers the option of throwing your image into the soup and being amazed at what comes out. It’s pure alchemy.

Once upon a time, back when I was a little bit, I too worked as a camera for hire. It was real fun, and possibly the most difficult job I have ever had.

It’s still analog on film. :stuck_out_tongue_closed_eyes:

Film is good because people don’t throw away negatives like most do with digital photos when the camera runs out of memory. You never know if maybe you could have used the shot which was deleted.

What’s the best camera in the world? The one you have with on you at the time.

1 Like

Hello everyone!

I’ve been messing with this on my projects and I think I might have found a solution to this “detuning” issue.

Since the oscillators are the problem and the keyboard seems to output consistent voltages depending on the key pressed, I figured that I could use an Arduino sketch to read which key was pressed - and then send a modified voltage value so the Oscillator can play the right sounds.

I published the sketch and the demo on the Projects page:

Finding a way to detect which key was pressed on the keyboard was by far the most painful part. After that was solved, testing the different note values to sound right was relatively easy.


And now for the next part. The pitches are accurate now, but I noticed that when using this the sound is slightly different, like there’s some sort of “ring” tone on top of the original sound. Does anyone have any idea why is that happening, or can check it with an oscilloscope?

1 Like

I think it is very sad that Littlebits don’t want to admit the serious detune problem which they have showed in earlier replies.
It is impossible to play clean with Littlebits keyboard and attached midi keyboards.
It works well with Littlebits sequencer as the voltage output is seamles.
But not with Arturias Beatstep or Korgs SQ-1 as they output the voltage in steps. Beatstep: 12 steps/octave and SQ-1: 24 steps/octave.
That is very sad as SQ-1 has two tracks there one track can for example run a Littlebits synth and the other for example Moog Werkstatt. But it is impossible to get the two synths in tune because of the imperfect Littlebits oscillator.
But the Werkstatt plays in tune with all sequencers I have tried so it is possible to design a cheap analog oscillator with perfect pitches.
I really hope that Littlebits change their mind and redesign the oscillator as all of their other synth bits are really good.

Hi @goncalofsilva!

Good job Gonçalo, I installed your software on my arduino bit, hooked it up, and heard exactly what you did. Then I used a split and looked at the signal on my antique oscilloscope, and here is the result:

As you can see, the waveform is jittery when the arduino is attached. I didn’t dig too far into your code, but I wonder if that ‘delay(50);’ statement has anything to do with it?

Chris, thanks for the video.

The delay(50) doesn’t seem to be the problem… I tested this sketch with a hardcoded C6 note (without reading the keyboard) and it does exactly the same noise:

#include "LittlebitsOscVoltages.h"

#define OSCILLATOR_PORT 5

void setup()
{
  pinMode(OSCILLATOR_PORT, OUTPUT);
  analogWrite(OSCILLATOR_PORT, LittlebitsOscVoltages::musicNote_toCorrectVoltageValue[LittlebitsMusicNote::C6] );
}

void loop()
{
   // use delay() or don't - it makes the same noise
}

I’m guessing it must be something related to how Arduino writes analog voltages.

1 Like

I took the sample after the oscillator. When I get a chance, I’ll look at what is coming from the arduino.

[quote=“goncalofsilva, post:25, topic:13415, full:true”]… I’m guessing it must be something related to how Arduino writes analog voltages.
[/quote]

It looks to me like the pwm frequency is not being completely filtered out. Here 's my setup, and the result. You can see there is some ripple coming out of the arduino. My guess is that it would require further filtration beyond what the analog-pwm switch provides.

(the 'scope is connected to the white (signal) and black (gnd) wires.)

Latest update!

So, I decided to give it one last try and searched for more information about how Arduino writes the PWM signal. (Leonardo’s datasheet, page 133: http://www.atmel.com/images/atmel-7766-8-bit-avr-atmega16u4-32u4_datasheet.pdf)

If you look in Arduino’s source code (file “wiring.c”) - by default the D5 and D9 ports use “Phase Correct PWM” (counting from 0x00 to 0xFF), but there are more PWM options there.

Most of them produced very distorted sounds, but “Fast PWM” (from 0x00 to 0xFF) seems to do the trick! So before any calls to analogWrite(), we need to change from “Phase Correct PWM” to “Fast PWM” like this:

#include "LittlebitsOscVoltages.h"

#define OSCILLATOR_PORT 5
void setup()
{
  pinMode(OSCILLATOR_PORT, OUTPUT);
  bitSet(TCCR3B, WGM32);   // <---- Switch the PWM mode used by Arduino.

  LittlebitsOscVoltages::musicNote_toCorrectVoltageValue[LittlebitsMusicNote::C6] );
}

After switching to that mode the buzzing stopped immediately. I don’t know exactly why it works, but… it works!

1 Like

Yay!

[quote=“goncalofsilva, post:28, topic:13415”]
… I don’t know exactly why it works, but… it works! …[/quote]

Because Fast PWM has a higher frequency, so the peaks are closer together and the ripple shown in the output will be reduced.

ps, please update your project’s file so it has your corrected sketch.

Done!

I added the Fast PWM mode for ports D5 and D9, and tested the correct pitches again.

The old sketch is still there as well. I haven’t found any button to remove it on the Edit page.

1 Like

Just wanted to share my experience -

I recently got the midi module so I could use a real keyboard, and at first I was super disappointed because the notes seemed completely flat and out of tune with each other. I read this topic and felt bummed out, questioning whether I had just wasted my money.

But it turns out that the tuning knob on the oscillator actually does work! Mine was just so far out of tune from the factory that I thought it was defective. It wasn’t until I realized that the tuning knob is actually controlling the interval between the notes that I was able to finally get it going.

1 Like

Hello, @scott! :smile:

You are not alone. Many people mistake the octave tuning pot for a fine tune pot. Once you get it set to octave intervals, you will not have to touch it again.

This is a pot normally hidden behind the case of a synthesizer, so normally a factory technician would adjust all of these fine tune pots before the synthesizer leaves the factory. Imagine calibrating ten or more of these pots per synthesizer, and having to ship hundreds of them per day! :scream: That is what a Moog technician does!

I think that all of the oscillator bits come from the factory with the octave tuning pot at the lowest value, so yes, they will all need to be calibrated. It’s all a part of the learning experience. :smiley:

1 Like

I’ve made a little video showing how to tune the oscillator: https://www.youtube.com/watch?v=aw8bpQrDaZM

2 Likes

Hi @dhilowitz,
You made a great tutorial !
I think Littlebits should add this to their official manual…
@JackANDJude ? :memo::musical_score:

Thanks for this very helpful tutorial, @dhilowitz! I’m sharing with the team now. :slight_smile: …looking forward to trying it, too. :thumbsup:

Hi,
Thank you very much for solving the tuning problem!
It has been a huge problem for me.