Dear Arduino folk! I need a simple playout controller for Audacity audio editor. Unfortunately Audacity does not support MIDI so I need to build something emulating Key-Shortcuts. I got an Arduino Mega but allthough I was searching the forum all day long and trying several offered sketches, without success, because most of the language is incomprehensible to me and it would take me years to learn -
I´m a "grown up" sound and electronics engineer from the ancient analog times...
Is there anyone having mercy with me ? Please help with copy/paste sketches I could try!
Thanks for any help! I will send a good bottle of Whiskey to the person who helps
Thanks and all the best to you! Marc
Hi Marc, first question is whether you have the right Arduino. Not all can emulate a keyboard/mouse. Which model of Mega do you have?
Are you planning to take input from some buttons then send Keypresses to the pc? Give us the vision for the completed project.
Cheers,
Rhys
Hi Rhys, ok that might be a point - it´s an older, but well working Mega 1280 I got from a friend. I wired five Buttons and two faders to it which i used so far as a simple MIDI-controller. Now I need to press virtual buttons via a hardware button. Play, Stop, Record. Many functions in Audacity can be well controlled via shortcuts. Play/Pause = Space, Record=R, but these settings can be changed easily in case needed.
The vision is helping a blind friend of mine recording his own songs.
If necessary I´ll get a different Arduino.
Thanks so much!
An Arduino Micro or Leonardo would be best for this. They can emulate a keyboard and send any key commands. The Micro is useful because it can be plugged into a breadboard. The Leonardo fits the "shield" pin layout, which may be useful if you already have a shield with buttons.
Other Arduinos can also do this, but those two are the best starting points.
Yes I agree. The micro is great I'm using them for a project at the moment involving sending HID keyboard presses and consumer keys using Nico's brilliant framework.
I suspect your Mega cannot emulate an HID device. It may be possible to make it do so but things will be much easier with the Micro. There will be a much less steep learning curve I think.
Great project by the way. Once you've got your Leonard or Micro drop back in and I'm sure we can get you up and running.
Whow, great meeting you guys! I didn´t know that Arduinos differ not only in size, memory and speed, but also funtionalities. I read the specs of Leonardo and Micro and now I sort of understand that they offer the right USB abilities for my needs. I´ll get a Micro at RS components for ~26Euros, bcause I suppose best is getting an original high-Q ArduinoBoard - any other recommendations or needs? I´ll be back as soon I have the board in hands. btw: my shield is just a couple of pinrows with soldered wires and resistors
I´m looking foreward! Cheers & have a nice weekend!
Hello again! It took me a while to get my jobs done, but now I´m back. Meanwhile I got an Arduino Micro, and five pushbuttons wired to inputs 2-6 and to ground. I opened example USB>Keyboard>KeyboardMessage, changed the code, so a pushed button reacts to LOW by setting the internal digitalWrite pullup resistor, so I don´t need to solder 10k pulldown resistors for every button and it worked right away triggering a text-message into Notepad. Fine!
Now the task is to create keyboard shortcuts to control functions in Audacity for my blind friend:
*Play/Stop and Set Cursor - SHIFT + A
*Loop Play - SHIFT + SPACE
*Mute/Unmute - SHIFT + M
*Solo - SHIFT + S
*Record - R
As far as I understood, I need to 'include "keyboard.h" library now, but I can´t find it anywhere!?
I found John Jurotte´s example http://www.instructables.com/id/Keyboard-shortcuts-using-Arduino/step13/The-Code/ - but its confusing me and I´m stuck...
Later I want to use a 6x6 matrix Keypad for 36 commands, because Micro has only 18 free inputs, but for a prototype the 5 functions listed above will do for now.
I renew my offer, that I will send a good bottle of Whisky to the one who can help with a working code
Cheers, Marc
Now I found a library here: https://sites.google.com/site/projectsmcd/ArduinoKeyboard.zip?attredirects=0&d=1
but trying to include it, I get an error
Also this here seems interesting:Google Code Archive - Long-term storage for Google Code Project Hosting.
but it contains a huge amount of data, I don´t know how to deal with?
I´d be grateful for any help! Thanks kindly!
Hi Marc, I don't have time for a few days to write/test some code but you should be able to do everything you need without additional libraries.
https://www.arduino.cc/en/Reference/KeyboardModifiers
You need to use key press/release methods to hold the modifier keys.
See how you go and if you're still having trouble I'll try to write some code on the weekend. I have spare micro here I can play with.
Cheers,
Rhys
Hi Marc,
Here are some examples. I've tested with Arduino Micro and verified with the Windows on screen keyboard.
void setup()
{
delay(5000);
ShiftA();
delay(1000);
ShiftSpace();
delay(1000);
ShiftM();
delay(1000);
ShiftS();
delay(1000);
KeyR();
delay(1000);
}
void loop() {
}
//Play/Stop and Set Cursor - SHIFT + A
void ShiftA()
{
Keyboard.press(KEY_LEFT_SHIFT);
Keyboard.press('A');
delay(50);
Keyboard.releaseAll();
}
//Loop Play - SHIFT + SPACE
void ShiftSpace()
{
Keyboard.press(KEY_LEFT_SHIFT);
Keyboard.write(0x20); //Spacebar
delay(50);
Keyboard.releaseAll();
}
//Mute/Unmute - SHIFT + M
void ShiftM()
{
Keyboard.press(KEY_LEFT_SHIFT);
Keyboard.press('M');
delay(50);
Keyboard.releaseAll();
}
//Solo - SHIFT + S
void ShiftS()
{
Keyboard.press(KEY_LEFT_SHIFT);
Keyboard.press('S');
delay(50);
Keyboard.releaseAll();
}
//Record - R
void KeyR()
{
Keyboard.press('R');
delay(50);
Keyboard.releaseAll();
}
I don't have buttons connected I'm just calling the methods in the setup routine.
Cheers,
Rhys
ooops - my harddisk reported errors last week, so I had to quickly do something. My wonderful community radio employee sponsored me a 500gb Crucial SSD, which took some days to arrive. Now after a two days lasting Clonezilla session I´m happy to be back online without much data loss! Off course I have backups, but what an effort having to setup everything from scratch! phew... - anyway, but I must say, that my Thinkpad boots like a rocket now!
Thanks for your effort Rhys!!! I´ll try your code tomorrow and let you know.
I´ll go to the pub now and cheer on you! Kind regards, Marc
Hello again, I was patiently trying to get just one shortcut "CTRL+M" (mute) work to begin with.
I know everything about sound & broadcast enginnering & electronics, but this was a riddle I tried to solve by trial & error, copy/paste junks of different people - which was rather gambling than knowing...
This "method" caused absolute mayham some hours ago. God thanks I use an old Laptop for programming, obeying the warning that Arduino emulating keyboards could cause unpredictable results as it did today morning... It was tricky getting out of this unstoppable loop of "SHIFT+M" - oh dear!
I obviousely looped the wrong codeline, but I´ve learned my lesson
In the past hours I combined the code from the keyboard example within Arduino 1.6.3, exchanged some of the loop section with some lines from Rhys Goodwin, had a good look at the keyboard modifiers and read the ASCII tutorial and others.
I understand now that I have to poll my hardware-buttons and define how they are wired, set pullup resistors and delay a little between multiple button-strokes not to confuse Audacity and now IT WORKS!!!!
Next task will be to include the 6x6 keypad for all necessary functions.
The code is on the other laptop, which is not connected to a network. After I finished the prototyping I will post my results here!
Thanks everybody for their generous help and the inventors of Arduino!!!
big respect and best regards,
Marc
where is my Whiskey
Haha, I shurely was looking completely stupid when I had endless rows of "MMMMMMMMMMMMMM..." on my screen - helplessly ripping out the USB to stop it. everytime I plugged the Micro in it started again - I felt sooo stupid! All I could do was switching off all the USBs and trying to upload any other code from the examples, to get rid of it. The laptop´s keyboard and mouse was completely useless because of this! It corrupted even when the Micro was unplugged, so I had to reboot the good old Thinkpad several times, until I somehow managed to upload the "Blink"-example - as I said, I´ve learned my lession Thanks for your humor! Thumbs up & cheers