I've just tested with your code, and same as you, the pitch is perfect, with my tuner (on my phone) it's around -2 and +2 cents.

Thanks again.


So I've had mine for quite some time and haven't got around to setting it up. I'm not sure if I ever will with all my projects going on, so I feel I should sell it.

Is anyone here interested?


The device itself is not expensive at all (30 € if I remember well), and you can get great sounds with it (it's also easy to use)

You're making really cool classical music, I'm sure this ym2151 shield would make a good addition. I'm sure you'll regret to sell it.


I'm not going to get any sound out of it unless I solder a MIDI port to it first, which I don't have the knowledge or patience for.


a late answer, but I've just remembered I forgot to answer to this one... You don't need to solder a real midi port, just scavenge an old midi cable and you can do something with that...


I added a Master-Tune Option in the Settings of the Midi-Controller Software. This was available as a Source Commit quite for a while now, but I never got around testing and making a Release Build of it. You can Download it from the Github page. Just be sure to also update the Firmware on the Arduino.

The Master Tune Value also gets saved in EEPROM on the Arduino, so you don't need to set the Master tune always.


late Answer, but now the Code should now work for all Versions of Arduino IDE currently available
btw, your link for the Controller Software on the github page for the Layout is wrong.

If you still want to build on 1.6.8, you need to change the line:
#include <EEPROM.h>
#include  <EEPROM/src/EEPROM.h>

brooklyn, NY

Cool.   I actually have been messing around and had added master tune myself with the eventual goal of pitch bend and portamento.   (Pitch bend seems fathomable...i have no idea how to implement portamento. ??)  Ill prob just go w/ your master tune routine in the future if i do any more work.
I also added a master volume control on CC#7, which i find pretty useful.   If you want, maybe we can roll this into 1.6.9.     pretty simple stuff.

Also, something Ive been noticing : (on my YM synth, at least)   that there is an annoying  'pop' or 'click' with every fast volume envelope trigger.   This can be heard best when playing fast notes on pads w/ a slow attack,  and/ or when the amp modulation is enable and LFO is set to  square wave.    it Has been bugging the hell out of me.   Pretty sure it is not hardware... seems like an issue w/ how software is resetting the volume in the chip.   Just wondering if anyone else is experiencing this.   if not, I guess it is something w/ my DAC or amp circuits.   

And lastly,   DET1  (fine detune)   on all OPs does not seem to work, or at least I cannot hear any difference at all, with any OP and w/ any algorithm.   I realize that it is subtle, but it seems like it isnt really working.   am I deaf?


I think it would be feasible to implement Portamento (I have some Ideas we could try) and Pitchbend.
I'll also add that Master Volume Knob (This would scale the Volume from 0 to whatever Volume you set for the Ops). Should be no Problem.

If you want, you can implement pitch bend or other features and send me the Files (or use github). Just be sure to use the newest Files from the github page. I will also maybe implement some features in the future.

I'm also getting these  'pop' or 'click' noises. I think it's not a Software problem. Maybe the Release is not quite done, when you trigger a new note. This would result in a  'pop' or 'click'  noise (This is also the problem with that Analog Modular Synth I got). The YM2151 sets the Audio Level back to 0, when a new note is triggered. With the Square Wave it is the same Problem. The change in Audio Level happens to quickly. I might investigate this further if I got some time.

DET1: I also first thought that it was not working, but I did test it and as far as I can tell my Code does nothing wrong. Its just really really subtle.

The problem with not being able to compile with 1.6.9 and newer Versions was the addition of some defines which sadly were named exactly like some Variables in YM2151.h. I just had to rename them and the sketch compiled again.

BTW: You should try out the Master Tune (use the Java Controller I created). The tuning range might not be wide enough. (For me it was enough to get the synth in tune, but it might not be for others). If its not enough, I also could change the Range.

Last edited by masl (Feb 20, 2017 1:34 am)

brooklyn, NY

The previous version of the arduino code had the subroutine :YM2151DriverClass::setVolume  which is what I used for the volume control.   It was unused and it looks like you removed it in 1.6.9.    I already went and added it and the rest of my volume stuff to the new version and everything seems to compile, load and run properly, so I can assume that there are no issues.  I can send it to you if you want.  Honesty, I do not understand how to contribute to a project on github, but I can try. create a fork?

Last edited by Charbot (Feb 20, 2017 2:51 am)

brooklyn, NY

Just tried the master tune via the java app.   Doesnt seem like it is working.    The whole synth is now 4 semi tones off -( C plays an E)
Changing the tuner in the app has no effect.

also tnanks for changing the default patch.  Was getting sick of that last one wink

Last edited by Charbot (Feb 20, 2017 2:36 am)


Did you try to Compile in Arduino IDE V1.6.9 or newer ?? Because for me the Code worked fine, but I compiled it in 1.6.8.
You have to retrigger a Note to hear the Change. Btw: You can set the Tune in the app from -63 to 64. (for me -42 was the one which worked)
Also if you type in a Value, you have to press enter for it to change. (or use the up and down buttons on the right side of the TextField.)
Did you choose the right Midi Devices in the Settings?

If all of this does not work, did you try to use the Code without Modifications? And did you download the newest Code from Github?
It's a bit weird, that it's 4 SemiTones off. The only thing I do is changing the kf Value in the setTone function in YM2151Driver.cpp

If really nothing happens when trying to change the Master Tune, did you ever send Sysex Messages over your Midi Interface? If not, you can use the Procedure explained here:
to try if your midi Interface does send Sysex Messages. If you don't want do download the Shareware they use in this tutorial, you also should be able to use MidiOx (

I think I did remove the setVolume Method because 1. it was unused and 2. it was not a function I had written and I had no Copyright on. And I thought it was very bulky and I did not quite understand what the Programmer did there. So I might rewrite it.

You can either post the Changes here, or I can write a PM with my email, where you can send me your Code. And don't forget to add your Name at the top of the Files you Modify.


Last edited by masl (Feb 20, 2017 11:42 am)

brooklyn, NY

Im using Arduino 1.8.1. w/ the latest controller software and arduino firmware.   (downloaded it last night.)      Controller app is fully connected;  I can send note commands, load patches, change parameters, etc.   
It appears that the java controller is not sending sysex master tune info.    Im using a MOTU ultralite mk3 interface and have never had an isssue sending sysex messages before.  In fact, I did it yesterday to another synth.   On this interface, when any kind of midi messages are being  routed, either in or out, the screen displays a "M".     Not seeing this when I set (and enter) the master tune parameter.    I also tried it with your 'stock' 1.6.9  (no volume stuff).

I dont get why it would be 4 semitones off either.   (Im using a boss tuner,   and everything is always dead-on-the-note, being off in solid 100 cent steps.      +64  should just be be just one semi tone up, right?

Last edited by Charbot (Feb 20, 2017 2:58 pm)

brooklyn, NY

Pm me w/ your email and I'll send you my version with volume back in.

brooklyn, NY

oh, btw.... I designed/built a hardware knobby controller for the YM2151, but Ive been lazy with the documentation

It uses a teensy 2.0.  All parameters have a pot or switch.  (w/ an extra in the bottom right corner... hoping for glide eventually)
Some features:
  *DIN IN and USB Midi IN/OUT
  *(More or less) Euro Rack sized.   As is, can be squeezed  into a rack if the mount tabs are thin.   Ill try to shave it down a little in future revisions
  *Assignable velocity (and eventually aftertouch) 
  *OLED Screen to display Alogorithm, LFO wave, preset #, midi channel, velocity destinations, etc
  *can store over 255 presets. Im using an adafruit FRAM breakout w/ 32K of nonvolotile memory and over a rillion write cycles.
  *...and  can load and save patches for Masl's Java based Controller App.  (Would be cool to get them talking both ways- being able to upload       
    patches from the hardware editor to the software one, functioning as a patch editor.)

Right now it is just a DIY er.   The boards are home etch-able,  However there is some surface mounted components.    The entire circuit is composed of 7 different boards, 6 of which have a SOP mux chip.    (Thinking of just using the actual FRAM chip instead of the adafruit breakout, so ultimately there will be a 7th surfave mounted part.) Not 'hard' , but maybe not for the novice.   Ill post the layouts and code on github eventually.   ...perhaps consider making/ offering boards in kit form where the all the surface mount stuff is already done

parts are about $100

Last edited by Charbot (Feb 20, 2017 5:19 pm)


Please try these three things and tell me which ones work?

Try to send a sysex with some other tool (e.g. Midiox) to the Arduino. Does the Tuning Change?:
      Use this Pattern: f0 4d 54 [Value] f7
      Where [Value] is something between 00 and 7f

Try to connect "The Control App" -> "Virtual Midi Port" -> "midiOx". Can you see the Sysex Messages?
       Follow this Tutorial on how to use MidiOx: … Controller

Try to use an older Version of the Arduino IDE (Version 1.6.8 because i know this works, because I tested)

Btw: Which OS and which Version of Java do you use?