Coder Social home page Coder Social logo

dlehenbauer / arduino-midi-sound-module Goto Github PK

View Code? Open in Web Editor NEW
58.0 58.0 6.0 10.27 MB

Turn your Arduino Uno into a 16-voice MIDI sound synthesizer

License: MIT License

C++ 31.41% Batchfile 0.12% C 1.98% Objective-C 66.48%
arduino arduino-uno general-midi maker midi sound-synthesis synthesizer

arduino-midi-sound-module's People

Contributors

dlehenbauer avatar per1234 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

arduino-midi-sound-module's Issues

Implementing Stereo (Controller Change 10)

Daniel,

I've got my breadboard of what you've outlined working wonderfully. Thanks for the awesome project! As a sort of beginner programming challenge I want to implement stereo using a second Arduino. I'm using input option 3, so both Arduino can listen to the same incoming midi stream (no need to try to send data from one to the other). If a midi signal implements panning then each Arduino would scale the volume by the appropriate value.

I've been digging through the source trying to follow (beginner C++ project for me, so trying to follow is half the battle) and it seems like I need to:

  • add a case in midisynth.h (0x0A) to handle incoming pan messages
  • offset the 0-127 value by 64 to get the "leftness" or "rightness" value as a 6-bit integer (perhaps looking at the high bit to determine if I need to reduce volume on the left or right side and the lowest six bits can be used directly as the multiplier on one Arduino and inverted on the other?? still working this out in my head...)
  • add a declaration to the .ino to build for let or right channel so I can decide which offset/multiplier to use from point above
  • potentially scale that integer to be 8 bits to make it easier to merge with the velocity and channel volume
  • figure out how to modify mixVolume to scale by my multiplier (I'm a bit unsure about how to go about this, since it seems like you've gone to some length to reduce the computational overhead of this by using some clever bit shifting instead of doing it a more straightforward way. Perhaps I need to add another stage (but I'm not sure if this would be fast enough or if there's a way to do it in one operation that would still be fast):
uint8_t monoVolume(uint8_t volume, uint8_t velocity) {
// Map 8-bit channel volume and 7-bit velocity to 7-bit mono volume.  We've scaled MIDI
// channel volume up to 8-bit so that we can perform an inexpensive '>> 8'.
return (static_cast<uint16_t>(volume) * static_cast<uint16_t>(velocity)) >> 8;
}
uint8_t mixVolume(uint8_t mixVolume, uint8_t stereoMultiplier) {
// Map 8-bit stereo multipler value and 7-bit mono volume to 7-bit final mix volume.
return (static_cast<uint16_t>(mixVolume) * static_cast<uint16_t>(stereoMultiplier)) >> 8;
}

Before I get off the deep end here, does that seem like a reasonable approach to take and do you have any advice to the above?

If this is too much feel free to close. Thanks again for making such a cool project!

Edit: presumably I'd want to drive both Arduinos from the same clock eventually so if it was converted to mono signal the samples would stay in phase.

Out of storage space error when compiling

I received the following error message when I compiled the project today:

"Sketch uses 32388 bytes (100%) of program storage space. Maximum is 32256 bytes.
Global variables use 1027 bytes (50%) of dynamic memory, leaving 1021 bytes for local variables. Maximum is 2048 bytes."

The Arduino IDE is version 1.8.10 and the target was an Arduino/Genuino Uno.

For my purposes, I don't need the MIDI Bend facility so I commented this out and it compiled successfully.

Display behaves differently on first play of midifile compared to subsequent plays

Hi,
Firstly thank you for developing this software. Given the hardware it runs on it is a remarkable achievement and it works really well.

I am working on a clock which I want to play the Westminster chimes, as per Big Ben in London, England. Having the clock play the respective MIDI files is a pleasing solution in terms of ability to get a good sound and be able to modify it. Your software makes that a proposition at a very reasonable cost compared to some of the Arduino MIDI solutions.

In the process of development I have encountered an odd phenomenon with the behavior of the display.

Please see the attached file which plays the hour chime melody followed by 6 hour strikes. While I probably won't use the display in final implementation I am having trouble seeing why the display behaves as it does.
west.zip

I am playing this file with Audacity configured to play into the LoopMIDI port then through the Hairless MIDI Serial Bridge to the Arduino which is on USB Port 7. The file plays as expected and sounds good. It is a very simple melody, effectively no chords and only one note at a time. The first time it plays the display shows notes sequentially across the voices as the notes play. First note shows on first voice, second on second voice and so on, until the 16 notes of the melody play out and all the hour strikes show on the first voice.

On all subsequent plays (until the Arduino is reset) the display shows notes on the first and second voices alternately, with the hour strike being on the first voice.

On first glance this looks like an initialization problem, and I started to look for that in the code. However this code, even the display part which is simpler, is complex as necessitated by what it does in such simple hardware. It seems to me that the display side of the code is correct and it is correctly reporting that each note is on a different voice for the first play. I cannot see why that is given the debug information from Hairless. See the attached image showing all notes going to channel 1.
west

I admit that this is not a desperate problem, but it is an interesting one and I hope you have the time to have a look.

Once again thanks for taking the time to develop such a great piece of software.

Kind Regards,
Fred.

What is the best way to "Pause" the synth?

Hi,

I am building a stand alone midi player based on the midi sound module and the MajicDesigns MD_MIDIFile file player. This is quite well along and it is basically working. I can read files from the SD, display their names on an OLED display, select a file and play it. This has been done by some copying of the the example Command Line Interface rather then by any feat of great genius on my part.

One of the functions supported by the file player is a pause function. However it does not work well. When paused the synth is not silenced and when restarted it sounds out of synch somehow. Some investigation of commands being sent shows that the problem seems to be linked to the file player. I will raise that with MajicDesigns.

My question relates to the best way to silence the synth on pause so that it can restart. I am not sure if channel command BX 78 0 (all sound off on channel X) works in the synth side and there is also BX 7B 0 (all notes off on channel X) which also looks like a candidate. Maybe there is another better answer?

I could be wrong but it seems I need to co-ordinate the file player with the synth so that one sends what the other is expecting. So I will start with the synth side and get an understanding and then move to the player side.

Regards, Fred.

Hanging Note Bug

Hi !

In most midi files i hear a hanging note thru the whole time.
If i press stop, the hanging note is gone...

Best regards
Paddy

Thank you, and a Favor

I've seen your demo and was amazed that you perfected this feat on an Arduino Uno!
Since your code didn't get the respect it deserved I posted this project on reddit and it was popular.
Your welcome.
Also, I can see potential in your project. I just have one favor; is there a way you could make the code to read a MIDI file from an SD card? If so, then that would really make the Arduino community happy.

Thank you for your time.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.