MIDI synth - noise on serial reception?

Yep, now I think it's a grounding issue.

I'm using the Sparkfun MIDI breakout, and I realized it still makes the noise when the Rx pin is disconnected via the switch.

But that breakout does have an optoisolated input, so shouldn't it be fine?
It appears to be isolated, based on the schematic: http://www.sparkfun.com/datasheets/BreakoutBoards/BOB-09598-MIDI_Breakout-v11.pdf

Other info on my circuit: the DAC's on a breadboard, connected to the Arduino just via 5v, gnd, clock, MOSI, and the slave select pin. It is already decoupled. The output of the DAC goes thru a 100uF cap to block DC, to the tip of the jack I'm using. The sleeve of the jack is to the ground row on the breadboard, which is to the Arduino ground.

The grounding issue must be with the MIDI connection; it's fine as long as there's no MIDI input. I even tried connecting a battery pack between the pins of the connector (obviously with the midi cable disconnected) and I get noise.
But it's theoretically isolated, so I don't know.

But that breakout does have an optoisolated input, so shouldn't it be fine?

MIDI inputs are always opto isolated, it is part of the spec.

The grounding issue must be with the MIDI connection;

No it is as you point out optically isolated so there can't be a grounding problem.

it's fine as long as there's no MIDI input.

Ring any bells?

I even tried connecting a battery pack between the pins of the connector (obviously with the midi cable disconnected) and I get noise.

When you do that you send a junk byte into the serial input.

I still think it's something related to grounding somehow.

If I remove the MIDI code and put in a Serial.begin(), then send stuff from the serial monitor in the IDE, no noise.

GRRRR... I can unplug the arduino entirely except for the MIDI cable and the audio output cable. And I still get the noise, but quieter. Something must be wrong with the breakout?

I plugged the cable into the aux in on my laptop and recorded the noise into Audacity. (don't have a proper oscilloscope... :stuck_out_tongue: )

Here are 2 of the clicks in the buzzing, normalized and with the space between them cut out (they're normally further apart)

could these be the MIDI messages bleeding through to the output somehow? not sure how that would happen.

Grumpy_Mike:
MIDI inputs are always opto isolated, it is part of the spec.

The data pins are opto-isolated. There is a third pin (ground) which is supposed to be connected at one end but not the other. Maybe noise is bleeding into that?

There is a third pin (ground) which is supposed to be connected at one end but not the other.

Yes but it is supposed to be connected at the MIDI out end not the MIDI in end. There should be no connection to that on the receiver as it kind of defeats the point of having opto isolation.

I mention it because perhaps it is in this case.

Nope. I checked the schematic, and checked the actual board too, and no connection.

sciguy:
GRRRR... I can unplug the arduino entirely except for the MIDI cable and the audio output cable. And I still get the noise, but quieter. Something must be wrong with the breakout?

With the MIDI cable disconnected is there any noise?

If it is connected but you don't connect the wire to the Rx pin of the board is there noise?

If you remove the serial reading (and the begin call) of the sketch is there noise?

If the MIDI device is powered down is there noise?

The noise is lots of short clicks, like in the screenshot of the waveform, one click I would assume for each MIDI message sent. Turning the mod or pitchbend wheels sends a ton of messages, so the clicks turn into a buzz. But there are also clicks at note on's and note off's. So yes, no noise without a MIDI cable connected, but that's irrelevant, since the noise only happens when a MIDI message is sent.

I have the breakout board mounted as a shield, so I can't physically disconnect a wire. But there is a switch that disconnects Rx, so the MIDI circuit doesn't interfere with programming the board. And yes, the clicking/buzzing still happens with that switch disconnecting Rx.

Yep. Assuming the DAC is already in active mode, i.e. not floating, I can upload the bare bones sketch with the empty setup and loop, and I still get the clicking/buzzing noise. So absolutely an electrical issue.

Again, no, but not relevant, since the clicking only occurs when a message is sent.

I'm still puzzled... I tried measuring the resistance between the MIDI connector pins and various points on the board, but nothing unusual. It seems to be isolated.

I think I would like to see a photo. The midi messages effectively are pulses at around 31250 KHz, so with a couple of 1 or 0 bits in a row you effectively have a square wave at 15625 Hz which would be audible, certainly.

You probably need to take steps to ensure that this digital "noise" (data, really) does not make it into your amp. So, shielded cable maybe. More decoupling caps on the DAC. If there is an amp, move it further away. Something like that.

Hi all,

I have a similar issue with one of my projects. I'm using an Arduino to send midi messages to a Roland TD6v sound module, essentially forming a basic step sequencer. In "free-running" mode (i.e. when the Arduino sketch provides its own timing/delays between steps, and no midi receive is used), the Arduino sends all of the right midi messages to the TD6v, and it sounds as expected. In "ext-sync" mode however (I.e. when the Arduino receives tick, start, and stop information from the TD6v), I get the same sort of audio "buzz" that you do at the start of each note.

I should also add that the sound module's midi buffer fills up (which it should not!) a few seconds after playing, like the individual notes are triggered many times. If I simplify the pattern to one hit per cycle, then I get the buzz but the midi buffer does not fill up. I'm pretty sure that there's no way that the midi messages themselves could loop between the devices ("note chase" and midi "soft thru" are turned off on the TD6v), so I'm assuming that there is some sort of grounding issue or something else that I'm unaware of. Perhaps there is some sort of power fluctuation, so the message appears to have been transmitted many times (pardon me if this sounds ridiculous… this is my first Arduino and midi project!).

I'm using the midi interface specified here (thanks to the author/designer!): http://www.stephenhobley.com/blog/2011/03/14/the-last-darned-midi-interface-ill-ever-build/

My next test will be to plug into a PC running some sort of midi message monitor so I can see what's happening on that front.

Any thoughts on this?

Thanks in advance to all.

So here's the circuit:

One thing I tried: I replaced the 220? resistor labeled R2 in the sparkfun schematic with a 1K? resistor.

That value seems to be the correct value according to the optoisolator datasheet, not the MIDI hardware spec. The noise is quieter with the larger resistor, but still audible. I also tried a 10K, but not much of a noticeable difference from the 1K.

And jman, here's a good midi monitor if you don't already have one: snoize: MIDI Monitor

Thanks Sciguy.

It turns out that I'm a bit of a muppet, in that my "noise" was all software/sketch related.

I'm running the sketch on a mega which has multiple com ports. I updated the sketch to use com1 for midi, so I could then use com0 for debug info (via serial monitor). I then output everin min i/o event to the debug port for review... which highlighted the issue almost immediately.

The sketch monitoring incoming midi "ticks" and updating two internal variables: currentTick and lastTick. Elsewhere in the program, I was testing these two variables for a difference between them (as a crude form of event detection) and then triggering the corresponding midi "note on" command accordingly. The trouble was that my SerialReceive() function was the only thing that updated the lastTick variable. The Loop() function cycled many times between the ticks, and consequently the event was triggered multiple times, creating a brief buzz sound at the start of each note (doh!). I changed the sketch to update the lastTick variable as soon as the current tick was processed (in addition to Serial.Receive) and all is now well and good :smiley:

This explains why the midi buffer on my sound module got so full so quick! Obvious in hindsight. But unfortunately this does not help you with the noise issues that you have with your synth! I almost feel bad now for poluting your thread with my problem :wink:

Best of luck with your synth. Be sure to upload some samples when it nears completion!

I've already uploaded samples, the noise is only an issue when using pitchbend or control messages, or low velocity notes. On notes with higher velocity, the click isn't noticeable.

Check out my soundcloud, link in my signature, for some samples, and also some songs I've made with the previous version of the synth.

So the noise has nothing to do with the DAC chip. I put 2 10k resistors in a divider arrangement, giving 2.5v, the same as the output of the DAC when no notes are playing. Then connected the output jack to the divider, bypassing the DAC, and I still get the noise with MIDI message reception.

I'm stuck... :~

Tomorrow I'll try making my own MIDI input circuit on a breadboard, to see if the sparkfun board's an issue.

Alright, so I fixed the problem! There's ZERO audible noise of any sort now, even when I turn up the gain on my mizer to far past comfortable levels!

The solution I found on ladyada's page for the waveshield:
http://www.ladyada.net/make/waveshield/design.html

Turns out (and it makes sense) that you need a very low lowpass filter inputting the Vref pins on the DAC. I had it originally connected directly to 5v, which was a very noisy power line. E.g. the optoisolator was drawing current when MIDI messages were received, so the voltage fluctuated.
The waveshield uses a 15Hz cutoff filter; I got much better results with a 0.033Hz filter. :astonished: It might take a second or two to ramp up to full voltage on startup of the synth, but I don't care, I have a little splash-screen anyway that appears.

Sorry for posting, this post is very old but I have a similar problem.
I made a dual pwm synth with mozzi library, it basically outputs an oscillator.

Here is the schematic:

The synth by itslef works fine, the audio output is very good.
The problem starts when I connect another device via MIDI INPUT, you can hear a very low frecuency wave that is made from the other synth's MIDI clock pulse. Also when a note gets received via MIDI in, it makes a click sound.

Here is a sound sample, first half with notes being received, last half with just clock (amplified):
https://dl.dropboxusercontent.com/u/103115555/autoobst%20midi%20crackle.mp3

the MIDI signal interfering with the audio output is very thin but it's there.
tryed to do a RC low pass filter on VREF and AVCC but it does nothing to mute those click sounds.

Also if I take out the Atmega chip, the sound's still there if MIDI is being sent.

Any idea??
Thanks :slight_smile:

Cross-posting irritates people. Thread locked.