It is currently Fri Mar 29, 2024 3:58 am


Arduino-based MIDI

Building organ consoles for use with Hauptwerk, adding MIDI to existing consoles, obtaining parts, ...
  • Author
  • Message
Offline

John L

Member

  • Posts: 46
  • Joined: Wed Jan 18, 2017 8:33 am
  • Location: Cumbria UK

Re: Arduino-based MIDI

PostSun Jan 22, 2017 5:36 am

Yes indeed, Nick. In fact there is no need in this application for anything like 0-127 granularity. Eight steps from minimum to maximum would probably do it and 16 definitely would.

Arduino's ADC provides an integer value in the range 0..1023. At the moment I am rounding that to 0 to 127 in steps of one but I think 16 steps of 8 would make more sense. That would significantly reduce MIDI traffic as a result of inconsequential changes of expression pedal position.

Edit: As it was only a one line change I tried out 16 steps of 8 and it seems to be just fine. The expression change per step is barely perceptible and MIDI traffic is now negligible.

Edit 2: I also changed the update rate to 100ms and again there is no discernible change in expression pedal behaviour. This means that an expression pedal can only ever create ten MIDI messages per second, which is negligible.
Offline
User avatar

organtechnology

Member

  • Posts: 1886
  • Joined: Sun Aug 02, 2009 4:58 pm
  • Location: DFW, TX USA

Re: Arduino-based MIDI

PostSun Jan 22, 2017 8:52 am

John L wrote:Yes indeed, Nick. In fact there is no need in this application for anything like 0-127 granularity. Eight steps from minimum to maximum would probably do it and 16 definitely would.

Arduino's ADC provides an integer value in the range 0..1023. At the moment I am rounding that to 0 to 127 in steps of one but I think 16 steps of 8 would make more sense. That would significantly reduce MIDI traffic as a result of inconsequential changes of expression pedal position.

Edit: As it was only a one line change I tried out 16 steps of 8 and it seems to be just fine. The expression change per step is barely perceptible and MIDI traffic is now negligible.

Edit 2: I also changed the update rate to 100ms and again there is no discernible change in expression pedal behaviour. This means that an expression pedal can only ever create ten MIDI messages per second, which is negligible.


I believe that many pipe organ swell shades have only 8 positions from open to closed but there are some crescendo switches with 40 positions on the switch. Hauptwerk Master Crescendo has a large number of virtual positions but I am not sure if it is greater than 40. It appears that even forty steps would require a 64 step resolution in the A/D for the pedal. Reference Arndt Organ Supply expression pedal with multiple reed switches for an example of this implementation. I have encountered MIDI implementations in Rodgers and Allen consoles that output stepped crescendo using program changes also. Perhaps 127 granularity is too much but if 64 steps are required is it really that much better than the standard 127?

Thomas

Edit1: The MIDI standard for 'granularity' appears to be 0-127. This applies to all A/D functions and note velocity.
Complete Hauptwerk™ systems using real wood consoles, PC Sound Engines, Dante Audio for Home or Church. info (at) organtechnology.com http://www.organtechnology.com
Authorized Hauptwerk; Milan Digital Audio and Lavender Audio reseller.
USA and Canada shipments only.
Offline

John L

Member

  • Posts: 46
  • Joined: Wed Jan 18, 2017 8:33 am
  • Location: Cumbria UK

Re: Arduino-based MIDI

PostSun Jan 22, 2017 11:30 am

I believe that many pipe organ swell shades have only 8 positions from open to closed but there are some crescendo switches with 40 positions on the switch.

I hadn't thought of crescendo controls. Such things didn't exist, on classical organ at least when I last did this sort of thing. I am having to get used to a lot of new terminology, which is all part of an interesting and fairly steep learning curve.

It's easy enough to have another class of control, as there are another eight analogue inputs to play with yet. One, or more (are there ever more than one?) could be assigned as a Crescendo class, with 64 values, or 128 or whatever seems appropriate. There is no need in this case to mess with the expression pedal code, which can be optimised for that function.
Offline
User avatar

NickNelson

Member

  • Posts: 880
  • Joined: Tue Dec 20, 2005 10:31 am
  • Location: Yorkshire, UK

Re: Arduino-based MIDI

PostSun Jan 22, 2017 2:14 pm

The range of 0-127 comes from the fact that any larger number becomes a status byte rather than a data byte. I entirely agree that a range of 0-64 is entirely appropriate for swells and, probably, crescendo controls.

The point I was making about truncation before deciding on whether the value has changed is more subtle though.

Consider the case where the actual value being detected is very close to the 0-1 transition of the least significant bit to be transmitted, but the resolution of the ADC is greater, say 10 bits:

0000110111
0000111000

Noise, and there always is some, which exceeds the least significant bit of the ADC can flip the 7th bit of what we want to transmit. Simply truncating the 10 bit to ADC result to 7 bits before determining whether a change has occured will not rectify the situation.

However, comparing the new and previous results at 10 bits, and deciding whether the change exceeds +/- 4 counts will inrease the noise immunity markedly.

0000110111
0000111000 +1 bit, no change
0000111001 +2 bits, no change
0000111010 + 3 bits, no change
0000111011 + 4 bits, no change
0000111100 + 5 bits, the value has changed

Nick
Offline
User avatar

organtechnology

Member

  • Posts: 1886
  • Joined: Sun Aug 02, 2009 4:58 pm
  • Location: DFW, TX USA

Re: Arduino-based MIDI

PostSun Jan 22, 2017 3:03 pm

NickNelson wrote:The range of 0-127 comes from the fact that any larger number becomes a status byte rather than a data byte. I entirely agree that a range of 0-64 is entirely appropriate for swells and, probably, crescendo controls.

The point I was making about truncation before deciding on whether the value has changed is more subtle though.

Consider the case where the actual value being detected is very close to the 0-1 transition of the least significant bit to be transmitted, but the resolution of the ADC is greater, say 10 bits:

0000110111
0000111000

Noise, and there always is some, which exceeds the least significant bit of the ADC can flip the 7th bit of what we want to transmit. Simply truncating the 10 bit to ADC result to 7 bits before determining whether a change has occured will not rectify the situation.

However, comparing the new and previous results at 10 bits, and deciding whether the change exceeds +/- 4 counts will inrease the noise immunity markedly.

0000110111
0000111000 +1 bit, no change
0000111001 +2 bits, no change
0000111010 + 3 bits, no change
0000111011 + 4 bits, no change
0000111100 + 5 bits, the value has changed

Nick


Empirical data indicates that the sensors used may be generating mechanical noise (value variations) rather than the circuitry or software. But it does seem to be the correct approach for the software interpretation of the values.

As for 100ms interval: I think you will be able to feel the lag in the value change as the pedal is depressed rapidly or it will cause large value changes which will sound/feel jerky.

Perhaps Nick's suggestion will allow more samples/second with less jitter and uncertainty.

Thomas
Complete Hauptwerk™ systems using real wood consoles, PC Sound Engines, Dante Audio for Home or Church. info (at) organtechnology.com http://www.organtechnology.com
Authorized Hauptwerk; Milan Digital Audio and Lavender Audio reseller.
USA and Canada shipments only.
Offline

jkinkennon

Member

  • Posts: 1208
  • Joined: Thu May 07, 2009 9:43 am
  • Location: Vancouver, WA

Re: Arduino-based MIDI

PostSun Jan 22, 2017 4:13 pm

Good point, Nick, about checking the ADC values prior to dropping excess bits. I think I can use that as I otherwise skip values either running the potentiometer either up or down -- can't recall which direction does that at the moment. I usually scan the pedals every 16 scans or so which would be every 16ms in my case. I have a few low priority tasks that I distribute around like this. I may read my slower I2C pistons and stops on scan 4, write any I2C stop changes on scan 8, read a different one of 8 potentiometers each odd scan. Basically I try not to do all these chores every key scan to keep things moving.

With the bus encoder I make sure I never wait for any key debouncing to complete and I use the peripheral SPI devices to read all four SPI busses at the same time. Each SPI device just happens to have it's own storage for exactly 128 keys (two manuals). I don't know whether efficiencies like these can be accomplished with Arduino.
Offline

JessieAMorris

Member

  • Posts: 2
  • Joined: Wed Oct 04, 2017 12:15 am

Re: Arduino-based MIDI

PostWed Oct 04, 2017 12:33 am

Hey,

Did you ever post the code for your Arduino system anywhere? I'm getting ready to convert a console and after looking at a lot of different options I felt like the Arduino gave me the best balance between long term support and cost.

I'm going to eventually be driving a pipe windchest as well, but the magnet relays for that require too much current for just an Arduino to drive alone, so I'll likely need to build a large MOSFET board.

Anyway, if you could share what you have so far it'd likely save me a lot of time!
Offline

John L

Member

  • Posts: 46
  • Joined: Wed Jan 18, 2017 8:33 am
  • Location: Cumbria UK

Re: Arduino-based MIDI

PostWed Oct 04, 2017 4:13 am

Hi Jessie,

Thanks for your interest in my Arduino MIDI project. In the end I purchased a console that came with its own MIDI hardware. As I really wanted to learn to play the organ (again), rather than take on yet another technical project, the Arduino MIDI code went into hibernation. I now look back on the work I did as a useful way of learning about MIDI and challenging some of the received wisdom that surrounds it. With hindsight it still seems like a reasonable and cost effective approach.

I still have the code but it hasn't moved on since January. I brushed the dust off and it still compiles! If you think it would be useful then I am happy to put it in the public domain as is.

John.
Offline

JessieAMorris

Member

  • Posts: 2
  • Joined: Wed Oct 04, 2017 12:15 am

Re: Arduino-based MIDI

PostWed Oct 04, 2017 9:59 am

Yeah, I think there'd be some great value in it still. At the very least it'd give me a starting point for the matrix scanning and swell logic.

I honestly think if we made this relatively easy to do that this could become a full fledged open source project. The cost for an arduino based system would likely be way cheaper than most of your commercial products. There's also the ability to support quite a bit more functionality than many commercial products.

Anyway, I'd love to see it.
Offline

John L

Member

  • Posts: 46
  • Joined: Wed Jan 18, 2017 8:33 am
  • Location: Cumbria UK

Re: Arduino-based MIDI

PostWed Oct 04, 2017 11:00 am

OK, here is the code:

https://www.dropbox.com/s/i47ac0esq77z6en/OrganMidiController.zip?dl=1

Usual caveats: no warranty of fitness for purpose, bugs are possible, support entitlement is equivalent to the amount you paid for it, YMMV, etc. Hope it's useful for someone.

John.
Previous

Return to DIY organ consoles / MIDI

Who is online

Users browsing this forum: No registered users and 2 guests