Arduino nano midi translator attempt (MidiSerial)

From circuitbending to homebrew stompboxes & synths, keep the DIY spirit alive!

Moderators: Kent, Joe., luketeaford, lisa

Post Reply
re8et
Learning to Wiggle
Posts: 37
Joined: Tue Feb 12, 2019 8:23 am

Arduino nano midi translator attempt (MidiSerial)

Post by re8et » Fri Aug 16, 2019 11:58 am

PS: If you want the code, from now on , ask it directly to cctv.fm, as I am not the author of the working code, this posted here is just an attempt (not working). The code is written for a Vbeat IN to MG Bastl out, but could be used for many other stuff.



Hi, I'm planning to put an arduino nano and some basic circuitry into a Microgranny.
Microgranny has some space inside where there should go the battery that can fit it.
I already added an extra midi input and should also add four more mono cv input jacks and possibly a button or switch.
The Nano should get the power directly from the Microgranny board 5v, otherwise I could add a 7805 to convert th 9v input.

What I would like to do is input a cv to the nano, that should be a 0-5v dc envelope (or monotron lfo-eg) with 100k serial resistor before an opamp.
use the analog ref of the board, plus the 3,3 voltage to feed an MPC 6004 quad opamp, that should scale all cv inputs into an acceptable range for the analog pin read of the nano without risking to blow it up.
the circuit for the input is basically the same as
the one seen here viewtopic.php?t=209561&postdays=0&po storder=asc&start=0

All cv inputs should be translated to a midi cc message ranging 0-127
for to control all 8 knobs from only 4 inputs, to do that I should add possibly a button on another analog input that would switch between the first 4 midi cc and the other 4, from the same input cv's. Otherwise just 4 are fine.

the sketch itself should include a midithroughfilter for the clock so none of it goes to the midi input of the nano, I only want to send out the midi cc, the clock sync if everything works and do not overflows over other midi, and the translated midi notes out.

I have set the incoming midi notes as constants, that should trigger a midi note on event for notes 0-5 for the granny to read.

The note trigger comes from a volca beat first 6 channels midi out.

Last the Arduino should output the midi Tx to the Microgranny.


I want to thanks the Tuesday late night machine for the cv part conversion of the sketch, but It ain't be tested yet, anyone could take a look at the sketch and see if there are some blatant errors in it??

Further credit: The original idea came after the volca beat trigger arduino project idea from Filip https://www.cctv.fm/post/volca-trigger-out-modification

Tnx.

Ps. Presumably all relevant midi should get out the nano tx channel and then fed into the MG.
You do not have the required permissions to view the files attached to this post.
Last edited by re8et on Wed Aug 28, 2019 12:45 am, edited 3 times in total.

re8et
Learning to Wiggle
Posts: 37
Joined: Tue Feb 12, 2019 8:23 am

Post by re8et » Sun Aug 25, 2019 8:12 pm

After a week of trials and errors, Filip from cctv.fm decoded to help< decided to help with the code. New code makes use of Temp Analog and it's compiling, whereas my merging effort was not a good one (EXPE)

For the new code I had changed what Arduino should receive from the Volca beat. Monitoring the V beat midi it seemed I had a different kind of message. (From the original Filip sketch).

So I changed some code.
the Midi noteon from 0x99 to 0x90.
and noteoff from 0x89 to 0x80.

The new code for the nano CH340 (chinese model-no usb native) is written using Midiserial.

Does anyone has an idea why Midi note on would be 0x99?
Is there a particular reason for this?

European volca vs USA-Canadian Volca midi handling??
Arduino internal midi decoding could differs from midi Ox??


Here is European Vbeat Midi Monitored through Midi OX, all ten notes in succession.
Image
Last edited by re8et on Wed Aug 28, 2019 12:46 am, edited 1 time in total.

User avatar
widdly
Super Deluxe Wiggler
Posts: 1096
Joined: Wed Jan 21, 2009 1:31 am
Location: australia

Post by widdly » Sun Aug 25, 2019 10:28 pm

0x8n note on, where n is the channel number (0..15)
0x9n note off, where n is the channel number.

0x89 and 0x99 is using channel 10, which is the standard channel for drums.
0x80 and 0x90 are using channel 1

The channel in the second byte applies to CC's as well as most other channelized midi data.

re8et
Learning to Wiggle
Posts: 37
Joined: Tue Feb 12, 2019 8:23 am

Re: Arduino nano midi translator attempt (MidiSerial)

Post by re8et » Wed Aug 28, 2019 12:38 am

Oh, that I did not know! Tnx

We got some overflow problems, trying to tweak the code a bit, we got lots of skipped messages on the Terminal print. I believe the timing clock is asking too much to the Nano, also polyphonic input have me worried. It's an evolving situation by now.

ixtern
Common Wiggler
Posts: 245
Joined: Mon Jan 22, 2018 4:34 am

Post by ixtern » Wed Aug 28, 2019 1:42 am

I you are unsure how to implement MIDI functionality you can always study Arduino Midi Library source code:
https://github.com/FortySevenEffects/ar ... di_library
(I have used this library in some my Arduino projects and it is really good).
Library has also very good documentation:
Documentation

re8et
Learning to Wiggle
Posts: 37
Joined: Tue Feb 12, 2019 8:23 am

Post by re8et » Wed Aug 28, 2019 4:49 pm

ixtern wrote:I you are unsure how to implement MIDI functionality you can always study Arduino Midi Library source code:
https://github.com/FortySevenEffects/ar ... di_library
(I have used this library in some my Arduino projects and it is really good).
Library has also very good documentation:
Documentation
Problem here is the Nano has not hadware Serial, all is coded with MidiSerial, which I'm having a hard time find where to study material, thank you anyway.

I am dissecting the code in smaller parts now, also in the code there is not a buffer.flush, so studying that part also.

tnx.

ixtern
Common Wiggler
Posts: 245
Joined: Mon Jan 22, 2018 4:34 am

Post by ixtern » Thu Aug 29, 2019 2:09 am

re8et wrote: Problem here is the Nano has not hadware Serial, all is coded with MidiSerial, which I'm having a hard time find where to study material, thank you anyway.

I am dissecting the code in smaller parts now, also in the code there is not a buffer.flush, so studying that part also.

tnx.
Don't know what kind of Nano you have but my Nano has hardware serial (RxD/TxD) and I had used it in my Arduino MIDI projects.

BTW. It doesn't matter if you are using hardware or software serial. Application should be written such way that you isolate transport layer (serial) from application layer (MIDI). And MIDI handlers is what important and worth of studying in this library.

re8et
Learning to Wiggle
Posts: 37
Joined: Tue Feb 12, 2019 8:23 am

Post by re8et » Thu Aug 29, 2019 1:36 pm

Terrible (good) News!

I have splitted the code in two temporarily

One part is JUSTMIDI and the other JUSTCC... a small flashback...

I have been monitoring the midi output and there was a flooding of midicc, with some midi timecode here and there, and no notes at all...

So I splitted, and skimmed the code. First to go was clock.
then all trigs out.
After the split the terminal and midiox monitor both were much more responsive on the in/out displaying of notes.
I realized thanks to midi ox that I was playing a wrong conversion for the MG to read.
the corrected lowest note now was 0x0.
took out the noteoff section because MG did not trig samples, she's monophonic, so it's good.

MG started playing the Vbeat pattern... Horrray!!!!

re8et
Learning to Wiggle
Posts: 37
Joined: Tue Feb 12, 2019 8:23 am

Post by re8et » Thu Aug 29, 2019 1:44 pm

ixtern wrote: Don't know what kind of Nano you have but my Nano has hardware serial (RxD/TxD) and I had used it in my Arduino MIDI projects.

BTW. It doesn't matter if you are using hardware or software serial. Application should be written such way that you isolate transport layer (serial) from application layer (MIDI). And MIDI handlers is what important and worth of studying in this library.
Midi handlers is what I think it is necessary to flush the buffer, I've been trying to implement it, without much success, while going with subtraction worked, at least for a splitted part of the code, correctly... the hard part is to know where is the floor ( available buffer bytes) before overflood hits...

re8et
Learning to Wiggle
Posts: 37
Joined: Tue Feb 12, 2019 8:23 am

Post by re8et » Thu Aug 29, 2019 1:45 pm

re8et wrote:Terrible (good) News!


(the TRIGONLY original code is working alone as originally written by cctv.fm)

re8et
Learning to Wiggle
Posts: 37
Joined: Tue Feb 12, 2019 8:23 am

Post by re8et » Fri Sep 06, 2019 6:54 am

Project completed.
The two parts of code had been merged back together, everything had been tested and works fine now.
I limited the final version to just one CC input for practicality.
Arduino get its power from the Microgranny onboard 7805.

PS: the final code is substantially different from the code posted initially.
For the full code ask Filip at www.cctv.fm.

Image
Image

Post Reply

Return to “Music Tech DIY”