0
Offline
Newbie
Karma: 0
Posts: 14
Arduino rocks
|
 |
« on: February 04, 2008, 12:49:36 pm » |
Shameless plug. I just wrote this. I thought some of you might need it. Let me know how it works for you.
|
|
|
|
« Last Edit: February 04, 2008, 01:53:06 pm by tvst »
|
Logged
|
|
|
|
|
Forum Administrator
Cambridge, MA
Offline
Faraday Member
Karma: 7
Posts: 3532
|
 |
« Reply #1 on: February 04, 2008, 02:32:03 pm » |
Wow, that looks awesome. One silly question: how do you provide a MIDI input to other programs on the computer? That is, what does it mean to define a MIDI endpoint (if that's the right terminology)? Or, rather, what's ALSA MIDI? Also, I added a link to ttymidi to the MIDI section of communication section of the interfacing with hardware page on the playground. There's a link there for a similar program for the Mac.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 14
Arduino rocks
|
 |
« Reply #2 on: February 04, 2008, 02:59:23 pm » |
Yes, it's ALSA MIDI, so it will work with all major programs. The page I linked has some more info about how it works and such. I'm glad you liked it 
|
|
|
|
|
Logged
|
|
|
|
|
FR
Offline
Full Member
Karma: 0
Posts: 105
|
 |
« Reply #3 on: February 04, 2008, 04:04:11 pm » |
Great, I was looking for something like that for a while now.
I'll give it a try.
Nicolas
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 14
Arduino rocks
|
 |
« Reply #4 on: February 07, 2008, 12:43:25 am » |
Oh, now I understand your question. Well, ALSA is the most-used Linux sound system. Even when you use JACK or whatever, the MIDI part is generally still handled by ALSA. So this means that most Linux MIDI-compatible programs will be interfaceable with ttymidi.
|
|
|
|
|
Logged
|
|
|
|
|
Forum Administrator
Cambridge, MA
Offline
Faraday Member
Karma: 7
Posts: 3532
|
 |
« Reply #5 on: February 07, 2008, 12:25:37 pm » |
Awesome.
|
|
|
|
|
Logged
|
|
|
|
|
FR
Offline
Full Member
Karma: 0
Posts: 105
|
 |
« Reply #6 on: February 24, 2008, 12:14:40 pm » |
I tried it (ubuntu FF) . Great !!!
FYI (and future release) : I noticed a tipo in the README/COMPILE (not a big deal) You mean apt-get install libasound2-dev when you say apt-get install libasound-dev
Thank U for that (including the doc)
Did you try it in real time with a master midi keyboard ?
Nicolas
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 14
Arduino rocks
|
 |
« Reply #7 on: March 26, 2008, 03:34:15 pm » |
Thanks for catching that typo. I'll fix the file in a bit. Did you try it in real time with a master midi keyboard ? I used it in real time before, but not with a master midi keyboard.
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 2
Arduino rocks
|
 |
« Reply #8 on: December 03, 2008, 12:59:15 pm » |
Hi! I've recently seen this project and i think it's awesome. I post here because I have some problems with ttymidi. I've done some changes to ardumidi_test.pde to check how other instruments sound (apart from piano): /* This file is public domain. Use it as you like. */
#include <ardumidi.h>
int ledPin = 13; int note_on = 0; byte [glow]count[/glow] = 0;
void setup() { Serial.begin(115200); pinMode(ledPin, OUTPUT); }
void loop() { if (!note_on) { [glow]midi_program_change(0, count); //Change instrument count++; //in each note[/glow] // play a Cminor chord on channel 0, at maximum volume (127) midi_note_on(0, MIDI_C, 127); midi_note_on(0, MIDI_E + MIDI_FLAT + MIDI_OCTAVE, 127); midi_note_on(0, MIDI_G + MIDI_OCTAVE, 127);
// The MIDI_* macros were created to make your life easier, but you // don't have to use them. You may enter numbers instead if you know // what you're doing.
note_on = 1; digitalWrite(ledPin, HIGH); }
else { // stop the Cminor chord midi_note_off(0, MIDI_C, 127); midi_note_off(0, MIDI_E + MIDI_FLAT + MIDI_OCTAVE, 127); midi_note_off(0, MIDI_G + MIDI_OCTAVE, 127);
note_on = 0; digitalWrite(ledPin, LOW); } delay(500); } Then I use ttymidi and timidity as shown in your web, but I only hear some instruments, not all. Some of them don't work, like 116 and 117 (and many others). I don't know if i'm doing something bad or is a problem of the program, but cheking instruments one by one gives me the same result. I'm using arduino-0012 in a kubuntu 8.10. Thank you very much for your help, and excuse me for my english, i'm kind of a rookie :-[
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 2
Arduino rocks
|
 |
« Reply #9 on: December 03, 2008, 01:01:42 pm » |
I forgot that to compile the sketchbook, i had to fix some problems with stdlib.h as shown in the first reply to this topic: http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1222985221/2I don't know if it could be a problem
|
|
|
|
« Last Edit: December 03, 2008, 01:02:41 pm by bolloyo »
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 4
Arduino rocks
|
 |
« Reply #10 on: December 18, 2008, 02:47:28 pm » |
Here is a quick sketch I did that makes your Danger Shield into a musical instrument... sort of.... it's about as useful as a thermin for making music Button 1 on the Danger shield starts the note slider 3 is the value of the note musical note slider 2 to is velocity of note slider 1 is pitch bend not really working as intended but hey this sketch is quick dirty... please improve on it if you have any good ideas on how to make the danger shield into a better musical instrument.. the next sketch I'm going to attempt with ttymidi is to use the danger shield as a midi control surface for SooperLooper see if we can get some Monome like functionality out of the Danger Shield 8-) I have a idea about using one of the Danger shield buttons as a mode selector and using the 7seg led display to feedback what mode we are in kinda like the Korg Kaossilator that way where not stuck with changing just three control values with the sliders then maybe using the knock sensor to tap in Tempo BPM & leds above knock sensor to flash back playback BPM does this sound useful at all??? or are all you guys happy with the sound slider example using the buzzer? ;D // Danger Board v1.0 ttymidi MIDI-through-USB for // linux using the Danger Shield v1.0 // By: Brian Lightfoot (brianlightfoot@gmail.com) // More info: http://make.nycresistor.com/ds-1.0 // http://www.varal.org/ttymidi/
//our setup stuff #include "_init.h" //ttymidi include #include <ardumidi.h>
void setup() { ds_init(); } // setup our varables here int note_on = 0; int slider1_value = 0; byte slider2_value = 0; byte slider3_value = 0; boolean button1_state = false; boolean button2_state = false; boolean button3_state = false; boolean last_button1_state = false; boolean last_button2_state = false; boolean last_button3_state = false;
void loop() { //read all our slider values & button states. slider1_value = analogRead(SLIDER1_PIN) * 17; slider2_value = analogRead(SLIDER2_PIN) / 8; slider3_value = analogRead(SLIDER3_PIN) / 8; button1_state = digitalRead(BUTTON1_PIN); button2_state = digitalRead(BUTTON2_PIN); button3_state = digitalRead(BUTTON3_PIN);
//Play note if button is pressed slider3 is value of note slider to is velocity of note if (button1_state && !last_button1_state) { delay(100); midi_note_on(0, slider3_value, slider2_value); note_on = 1;
} // turn of note if slider3 was moved must hold button down and sweep slider3 back across // to turn note off else if (button2_state && !last_button2_state) { // turn off notes when slider pot is in same position or when sweeped back //across value need to change this.... to somthing more functional midi_note_off(0, slider3_value, slider2_value); note_on = 0; }
//write values directly to our leds for led brightness. midi_pitch_bend(0, slider1_value); analogWrite(SLIDER1_LED_PIN, slider1_value); analogWrite(SLIDER2_LED_PIN, slider2_value); analogWrite(SLIDER3_LED_PIN, slider3_value); }
|
|
|
|
« Last Edit: December 19, 2008, 04:23:50 am by brianlight »
|
Logged
|
I PITY DA FOOL WHO DON'T HACK ARDUINO!!!! 
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 4
Arduino rocks
|
 |
« Reply #11 on: December 21, 2008, 06:26:56 am » |
Here is a posting of more unfinished but working code of a Danger Shield midi control surface for Linux that I'm making using ttymidi. Was changing pitch & other effect values in TerminatorX I was also scratching loops with the sliders... Feedback would be great.. // Danger Board v1.0 ttymidi MIDI-through-USB for // linux using the Danger Shield v1.0 // By: Brian Lightfoot (brianlightfoot@gmail.com) // More info: http://make.nycresistor.com/ds-1.0 // http://www.varal.org/ttymidi/
//our setup stuff #include "_init.h" //ttymidi include #include <ardumidi.h>
void setup() { ds_init(); } // setup our varables here int modecount = 0; int note_on = 0; int seg = 255; int slider1_value = 0; byte slider2_value = 0; byte slider3_value = 0; boolean button1_state = false; boolean button2_state = false; boolean button3_state = false; boolean last_button1_state = false; boolean last_button2_state = false; boolean last_button3_state = false;
void loop() { //in this while loop we have instrument mode while(modecount == 0) { // Show mode on 7-segment // change this to usefull output in the future int seg above is value digitalWrite(LATCH_PIN, 0); shiftOut(DATA_PIN, CLOCK_PIN, LSBFIRST, seg); digitalWrite(LATCH_PIN, 1); //read all our slider values & button states. slider1_value = analogRead(SLIDER1_PIN) * 17; slider2_value = analogRead(SLIDER2_PIN) / 8; slider3_value = analogRead(SLIDER3_PIN) / 8; button1_state = digitalRead(BUTTON1_PIN); button2_state = digitalRead(BUTTON2_PIN); button3_state = digitalRead(BUTTON3_PIN);
//Play note if button is pressed slider3 is value of note slider to is velocity of note if (button1_state && !last_button1_state) { delay(100); midi_note_on(0, slider3_value, slider2_value); note_on = 1; } // turn of note if slider3 was moved must hold button down and sweep slider3 back across // to turn note off if (button2_state && !last_button2_state) { // turn off notes when slider pot is in same position or when sweeped back //across value need to change this.... to somthing more functional midi_note_off(0, slider3_value, slider2_value); note_on = 0; } //Change the mode if button 3 pressed break the while loop if (button3_state && !last_button3_state) { modecount++; }
//write values directly to our leds for led brightness. analogWrite(SLIDER1_LED_PIN, slider1_value); analogWrite(SLIDER2_LED_PIN, slider2_value); analogWrite(SLIDER3_LED_PIN, slider3_value); } // this while loop is controller mode while(modecount == 1) { //read all our slider values & button states. slider1_value = analogRead(SLIDER1_PIN) * 17; slider2_value = analogRead(SLIDER2_PIN) / 8; slider3_value = analogRead(SLIDER3_PIN) / 8; button1_state = digitalRead(BUTTON1_PIN); button2_state = digitalRead(BUTTON2_PIN); button3_state = digitalRead(BUTTON3_PIN); seg = 254; digitalWrite(LATCH_PIN, 0); shiftOut(DATA_PIN, CLOCK_PIN, LSBFIRST, slider3_value); digitalWrite(LATCH_PIN, 1); if (button1_state && !last_button1_state) //slider 3 controls the byte for what controller is used this is going to change to a button press in the near future just testing code here :D //slider 2 controls the value of the control used { midi_controller_change(0, slider3_value, slider2_value); note_on = 1; } //Change the mode if button 3 pressed break the while loop if (button3_state && !last_button3_state) { modecount--; } analogWrite(SLIDER1_LED_PIN, slider1_value); analogWrite(SLIDER2_LED_PIN, slider2_value); analogWrite(SLIDER3_LED_PIN, slider3_value);
} }
|
|
|
|
« Last Edit: December 21, 2008, 06:32:33 am by brianlight »
|
Logged
|
I PITY DA FOOL WHO DON'T HACK ARDUINO!!!! 
|
|
|
|
indonesia
Offline
Newbie
Karma: 0
Posts: 8
Arduino rocks
|
 |
« Reply #12 on: May 07, 2009, 12:27:15 am » |
Iam also have problem whwn make compiling in terminal p:/home/inot/Dokumen/ttymidi# # list available MIDI output clients root@inot-desktop:/home/inot/Dokumen/ttymidi# aconnect -o client 14: 'Midi Through' [type=kernel] 0 'Midi Through Port-0' client 16: 'Ensoniq AudioPCI' [type=kernel] 0 'ES1371 ' client 128: 'TiMidity' [type=user] 0 'TiMidity port 0 ' 1 'TiMidity port 1 ' 2 'TiMidity port 2 ' 3 'TiMidity port 3 ' client 129: 'TiMidity' [type=user] 0 'TiMidity port 0 ' 1 'TiMidity port 1 ' 2 'TiMidity port 2 ' 3 'TiMidity port 3 ' client 130: 'TiMidity' [type=user] 0 'TiMidity port 0 ' 1 'TiMidity port 1 ' 2 'TiMidity port 2 ' 3 'TiMidity port 3 ' client 136: 'TiMidity' [type=user] 0 'TiMidity port 0 ' 1 'TiMidity port 1 ' 2 'TiMidity port 2 ' 3 'TiMidity port 3 '
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 14
Arduino rocks
|
 |
« Reply #13 on: May 16, 2009, 04:13:05 pm » |
bolloyo: strange... I will check it out and get back to you.
tony: that's not how you compile it. As described in the file called README, you should compile with
gcc ttymidi.c -o ttymidi -lasound
|
|
|
|
|
Logged
|
|
|
|
|
0
Offline
Newbie
Karma: 0
Posts: 14
Arduino rocks
|
 |
« Reply #14 on: October 03, 2009, 11:51:36 am » |
So, I went on and made a project page at launchpad. You can post bugs there from now on. https://launchpad.net/ttymidi
|
|
|
|
|
Logged
|
|
|
|
|
|