Go Down

Topic: Reaper DAW triggering Arduinos (Read 3306 times) previous topic - next topic

Saynomore

Hi,

I would like to know if it's feasible (and if so, how to do it) to have my Reaper's play button acting as a trigger to start several Arduinos programs at the same time and the stop button to stop them.

I need to have them run their programs from the beginning of a track and following it in sync.

Thanks in advance for your help. 

slipstick

Reaper, like most DAWs, can start, stop and synch with external MIDI devices. An Arduino can be programmed to act as an external MIDI device. You won't actually be starting the program on the Arduino(s) because it will have to be running all the time in order to pick up the MIDI commands, but you can arrange for a MIDI command to start a sequence of actions.

So I guess it's possible but probably not exactly easy, though that will also depend on what exactly you want the Arduino(s) to do in synch with Reaper. How much Arduino programming and electronics experience do you have?

Steve

Saynomore

@slipstick Thanks for these explanations !

What I want to do is to have several Arduinos controlling motors and I need these motors to be triggered at certains points of my sound track. That's why I want to have everything to be launch at the same time.

It can also be some sort of button triggering the playback in Reaper and the Arduinos as well.
Something like this: https://www.youtube.com/watch?v=ntjO0XXJPhE
but with a method to trigger other Arduinos at the same time.

I don't know which one is the easiest or if there is a better way.

To answer you, I'm a beginner. I took some Arduino courses but it's been a while and I forgot a lot of stuff.

slipstick

How closely synchronised to the sound track do the actions of the Arduinos need to be? If it's just within a second or two you could probably get away with them free running, just using internal timing. In that case you just need a start/stop switch that operates both Reaper play and the Arduinos. Not too difficult to set up.

OTOH if they want to be accurate I would probably do it using MIDI. In Reaper you could set up an additional MIDI track with silent "notes" at all the appropriate trigger points and send that track's MIDI out to the Arduinos to get them each responding to their commands at exactly the right time. There are MIDI libraries that make MIDI access for Arduinos reasonably easy and the hardware is easy enough.

Sounds interesting and with a number of different ways to attack it depending on the precise specifications.

Steve

Grumpy_Mike

I would use Reaper to send some control messages to the Arduinos. They listen to the MIDI channel and act on the control message. Note with turning on a motor their will be a bit of inertia so you might want to trigger a beat or two before you want to see the effect.

Saynomore

@slipstick One second or two seems to be quite a bit to work along the sound track... Unless I move my sound track to start one second or two later. Do you think it could work?
If so and if this setup is easier, I'll go for that.

The "piano roll timeline triggering" was my first option but it looks way more difficult to do (for accelerations, speeds, direction, etc). Also, I will already have my octophonic sound track playing in Reaper plus 8 channels processing real time audio at the same time in Reaper. So if I add 8+ more MIDI tracks handling my Arduinos I think my 2008 macbook pro will explode. And it also means that I would need to have my Arduinos constantly plugged in my computer...

@Grumpy_Mike See what I said above. And about the delay induced by inertia I will take that into account in my timings.

Thanks for your help guys!


Grumpy_Mike

Quote
The "piano roll timeline triggering" was my first option but it looks way more difficult to do (for accelerations, speeds, direction, etc)
Why do you say that? I think you are wrong here.

Quote
So if I add 8+ more MIDI tracks handling my Arduinos I think my 2008 macbook pro will explode.
No the MIDI traffic over those links will be very sparse.

Quote
And it also means that I would need to have my Arduinos constantly plugged in my computer.
Why, if you don't plug them in then they will simply just not work.

Trying to synchronise two free running systems with just a start signal is not going to work, they will drift out of sync in an unrepeatable way due to temperature variations. Do some tests and see for yourself.

slipstick

#7
Sep 27, 2017, 05:46 pm Last Edit: Sep 27, 2017, 05:47 pm by slipstick
There's no reason why you would need 8+ extra tracks (though that is unlikely to be a problem). If your commands to the Arduinos are fairly simple then there's nothing stopping you from using a number of different MIDI commands on a single track. But at some point you are going to have to define exactly what commands you're going to want to send to the Arduinos and what they're doing with them.

And for that matter how you sure are you that you really need lots of Arduinos. It's possible to drive quite a few things with just one of them.

But face it if you want the Arduino(s) actions to be synchronised with sounds playing on the computer that isn't going to happen unless they are connected in some way to the computer.

Steve

Saynomore

@Grumpy_Mike I said that because I'm a beginner...
Also, I don't understand what you mean by "drifting out of sync due to temperature variations". Arduinos have an internal clock right? So why would the timings in my code be messed up? I'm confused.

@slipstick You're right about the number of tracks. I got my wires crossed.
If you don't consider the Reaper playback part, the commands I want my Arduinos to execute are pretty simple (that's why I already am able to code them myself, more or less (I don't think they're really optimized...)). It's just basic motor controls + LEDs lighting at the same time. But that said, I truly need one Arduino per "machine".

I will try to explain what I want to achieve in a more detailed way:

-I have an octophonic sound track in Reaper.
-I want to build 8 modular machines. By "modular" I mean that I will make 8 "bases" with an Arduino, a guitar preamp and a DI box in each one of them and then make several interchangeables "trays" to put and connect on top of them. They will have motors (solenoides, stepper, servo, DC, etc, depending of the needs of each machine) I want to connect to the Arduino and piezo mics to the preamp in this base.
-Picked up sounds will go from my DI boxes into my audio interface, to 8 channels in Reaper handling them in real time and mapping them into the same outputs as the sound track.
-These 8 machines will be triggered at certains points of the sound track, therefor make a sound which will be added to my sound track and be transmitted to the speakers.

That's why my first idea was to have an Arduino master connected to my computer to trigger the sound track in Reaper and launch the programs of all these 8 Arduino slaves at the same time.

I hope it's a bit more understandable...

The less wires, the better(but I'm setting aside RF or bluetooth transmissions for now as I don't want to make this more of a headache than it already is) . The more straight forward code and installation, the better.

I begin to get lost with all the possibilities to achieve that, and I don't have so much time to complete this project and I really don't know how to separate the wheat from the chaff to be the most efficient possible...

Grumpy_Mike

Quote
Also, I don't understand what you mean by "drifting out of sync due to temperature variations". Arduinos have an internal clock right? So why would the timings in my code be messed up?
The Arduino's clock is either a crystal oscillator or a resonator. Both have a temperature coefficient, but the resonator is greater. This means when you zoom into the exact frequency of the Arduino's clock you will find it will change slightly with temperature. This means it can never be relied upon to produce the same time delays from one run to the next. This difference gets bigger the longer the system has run from a synchronisation event. In effect it is exactly the same as when you tried to synchronise a tape recorder and a movie film projector. Just like that the two systems will drift. It is a fundamental law of physics that free running oscillators will drift unless locked together.

Quote
I begin to get lost with all the possibilities to achieve that, and I don't have so much time to complete this project and I really don't know how to separate the wheat from the chaff to be the most efficient possible
Keep it simple and don't add too many features at one go. Start simple and do as much as you can in the time you have.

slipstick

At the moment I'm guessing that each of the Arduino machines will have it's own fixed sequence of actions which just needs to be started and perhaps stopped at specific points in the playback. If so then you can just use a different "note" for each machine and your trigger track will then contain long "notes" to cover the times when each machine is to be active. The code needed to receive MIDI commands is not trivial but there are many examples and decent libraries available (and the project is interesting enough that you'll probably have plenty of help ;))

You could make it more complex with a whole series of commands that each "machine" needs to obey but that's probably overkill (maybe for a later project).

But either way if you're already running sound from DI boxes back to the computer then you could always use cables with more cores and run both sound and MIDI on them so you only have a single cable to each machine station.

I'd probably start by making a single Arduino "machine" that just receives MIDI note on/note off commands (a specific note on a specific channel) and switches an LED on and off. Once you have that working you're almost there.

Steve

Saynomore

@Grumpy_Mike I didn't know that. Thanks for this clear explanation.

Keep it simple and don't add too many features at one go. Start simple and do as much as you can in the time you have.
That's what I'm trying to do.

At the moment I'm guessing that each of the Arduino machines will have it's own fixed sequence of actions which just needs to be started and perhaps stopped at specific points in the playback. If so then you can just use a different "note" for each machine and your trigger track will then contain long "notes" to cover the times when each machine is to be active. The code needed to receive MIDI commands is not trivial but there are many examples and decent libraries available
You're right, that's exactly what I want to do.
But do I absolutely need to go through Processing like in this video: https://www.youtube.com/watch?v=cZmtrPImZaI  ?
That's the only example I found of Reaper MIDI track sending informations to Arduino...

I'd probably start by making a single Arduino "machine" that just receives MIDI note on/note off commands (a specific note on a specific channel) and switches an LED on and off. Once you have that working you're almost there.
I'will try that once I found how to make them communicate together.

(and the project is interesting enough that you'll probably have plenty of help ;))
Well, that's what I was seeking with this thread (and some others threads elsewhere) but unfortunately I'm still a bit stuck for now. But thanks for your suggestions and starting points guys. :)

slipstick

It shouldn't be nearly as complicated at the Reaper end as that video suggests. But since I've never actually done it I'd better test my theories myself before I tell you how easy it is;).  Give me a few days, I don't have a lot of spare time just now.

Steve

Saynomore

It shouldn't be nearly as complicated at the Reaper end as that video suggests. But since I've never actually done it I'd better test my theories myself before I tell you how easy it is;).  Give me a few days, I don't have a lot of spare time just now.

Steve
That's really nice of you!!
Thanks a lot, I genuinely appreciate your help!

Let me know. :)

Johan_Ha

That's the only example I found of Reaper MIDI track sending informations to Arduino...
I don't think you need examples of Reaper sending MIDI info to Arduino.
Just
  • figure out how you connect Reaper to external MIDI devices through USB. Probably just set your dedicated track in Reaper to some midi channel no other instrument or device uses.
  • figure out how to read incoming data from the USB to Arduino as MIDI data.

An alternative to Arduino reading MIDI data through its USB is to build a separate midi connection for your Arduino, say with DIN contacts (old school MIDI standard). Then you need a USB to MIDI converter.
____________________
- One day my stepper motor driver works like a charm. No task is too big for it and I can do anything with it. Next day it refuses to work and even the tiniest motor blows its fuse. What's wrong with it?
- It's bipolar.

Go Up