Go Down

Topic: ttymidi - software for MIDI-through-USB for Linux (Read 10592 times) previous topic - next topic

tvst

Feb 04, 2008, 06:49 pm Last Edit: Feb 04, 2008, 07:53 pm by tvst Reason: 1
Shameless plug. I just wrote this. I thought some of you might need it. Let me know how it works for you.

mellis

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.

tvst

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 :)

nrolland

Great, I was looking for something like that for a while now.

I'll give it a try.

Nicolas

tvst

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.


nrolland

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

tvst

Thanks for catching that typo. I'll fix the file in a bit.

Quote
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.

bolloyo

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):
Code: [Select]
/*
 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  :-[

bolloyo

#9
Dec 03, 2008, 07:01 pm Last Edit: Dec 03, 2008, 07:02 pm by bolloyo Reason: 1
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/2

I don't know if it could be a problem

brianlight

#10
Dec 18, 2008, 08:47 pm Last Edit: Dec 19, 2008, 10:23 am by brianlight Reason: 1
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
Code: [Select]
// 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);
}



I PITY DA FOOL WHO DON'T HACK ARDUINO!!!!
[IMG]http://www.threadbombin

brianlight

#11
Dec 21, 2008, 12:26 pm Last Edit: Dec 21, 2008, 12:32 pm by brianlight Reason: 1
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..  :D
Code: [Select]
// 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);

}

}
I PITY DA FOOL WHO DON'T HACK ARDUINO!!!!
[IMG]http://www.threadbombin

TonyMaryana

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 '

tvst

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


tvst

So, I went on and made a project page at launchpad. You can post bugs there from now on.

https://launchpad.net/ttymidi

Go Up