Pages: 1 ... 8 9 [10] 11   Go Down
Author Topic: works: MIDI-IN: code + schematics  (Read 43566 times)
0 Members and 1 Guest are viewing this topic.
France
Offline Offline
Sr. Member
****
Karma: 0
Posts: 262
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

From what I understood it is a different voltage level, so that's a bit more than precaution.
(BTW that's why the 3.3k resistor is 1k if a FTDI is connected.)
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 75
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey Tep,
just tried your circuit (again). Like before, the opto seems to function(via LED) but my arduino read nothing.   I have already tried different resistor combos with the (working)cny17-4.  As far as I can tell, it seems pretty forgiving, midi data gets through every time.  
There has to be some hardware problem going on here.  It doesnt read midi even when the opto is bypassed and the midi connected directly to the arduino.  THis should work.  There is no need for any kind of filter or anything, is there?
« Last Edit: February 23, 2010, 11:30:07 am by Charbot » Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 75
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Oh, another thing....
I may have already mentioned this , but I did get a 4n28 to work,once.
I dont know what I did, but after like, the umpteenth  build it just worked, briefly...until I disconnected the rx lead.  When I put it back in place it would no longer communicate. At first I though that it was definately a continuity issue but everything checked out, and since it works fine now with a cny17-4, i know it cant be  bad or loose connection.
Logged

Greenwood, Indiana
Offline Offline
God Member
*****
Karma: 0
Posts: 508
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The resistance is RBE and is mentioned in the datasheet. It's measured in kohms from 10k to 1meg. And it does cut down noise. It also has an affect on Ton.

http://www.fairchildsemi.com/ds/4N/4N28-M.pdf



Logged

If it was designed by man it can be repaired by man.

berlin
Offline Offline
Full Member
***
Karma: 0
Posts: 154
fubbi.com
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hi

i am looking for a solution to extract a beat out of Midi Time Code. I want to cycle four relays in the tempo of whatever is running. 1-2-3-4, 1-2-3-4, 1-2-3-4 etc

With this schematic and an arduino, is it all possible? Is there a "click" in the MTC or somewhere else in MIDI that I will be able to read with the arduino?

I will not be able to loop a note. I have to get it out of some kind of general system message stream or time code.

thanks

fubbi
Logged

France
Offline Offline
Sr. Member
****
Karma: 0
Posts: 262
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes you can.
Have a look at the doc:
http://home.roadrunner.com/~jgglatt/tech/midispec.htm

In the worst case, if you don't get it working or think it is too complex for you now, have a midi loop sending standard Midi CC.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 7
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Like Chris L here above I'm having a problem making my Arduino read a poly midi signal.

When I send a MIDI signal from my TC Electronics Konnekt 48 it works fine and polyphonic works, but when I use my MOTU UltraLite it only receives a mono signal.

Here is the code I am using
Code:
//variables setup

byte incomingByte;
byte note;
byte velocity;


int statusLed = 13;   // select the pin for the LED


int action=2; //0 =note off ; 1=note on ; 2= nada


//setup: declaring iputs and outputs and begin serial
void setup() {
  pinMode(statusLed,OUTPUT);   // declare the LED's pin as output
  pinMode(2,OUTPUT);
  pinMode(3,OUTPUT);
  pinMode(4,OUTPUT);
  pinMode(5,OUTPUT);
  pinMode(6,OUTPUT);
  pinMode(7,OUTPUT);
  pinMode(8,OUTPUT);
  pinMode(9,OUTPUT);
  
  //start serial with midi baudrate 31250 or 38400 for debugging
  Serial.begin(31250);        
  
}

//loop: wait for serial data, and interpret the message
void loop () {
  if (Serial.available() > 0) {
    // read the incoming byte:
    incomingByte = Serial.read();

    // wait for as status-byte, channel 1, note on or off
    if (incomingByte== 144){ // note on message starting starting
      action=1;
      digitalWrite(statusLed,HIGH);
    }else if (incomingByte== 128){ // note off message starting
      action=0;
      digitalWrite(statusLed,LOW);
    }else if (incomingByte== 208){ // aftertouch message starting
       //not implemented yet
    }else if (incomingByte== 160){ // polypressure message starting
       //not implemented yet
    }else if ( (action==0)&&(note==0) ){ // if we received a "note off", we wait for which note (databyte)
      note=incomingByte;
      playNote(note, 0);
      note=0;
      velocity=0;
      action=2;
    }else if ( (action==1)&&(note==0) ){ // if we received a "note on", we wait for the note (databyte)
      note=incomingByte;
    }else if ( (action==1)&&(note!=0) ){ // ...and then the velocity
      velocity=incomingByte;
      playNote(note, velocity);
      note=0;
      velocity=0;
      action=0;
    }else{
      //nada
    }
  }
}

void blink(){
  digitalWrite(statusLed, HIGH);
  delay(1000);
  digitalWrite(statusLed, LOW);
  delay(1000);
}


void playNote(byte note, byte velocity){
  int value=LOW;
  if (velocity >10){
      value=HIGH;
  }else{
   value=LOW;
  }

 //since we don't want to "play" all notes we wait for a note between 36 & 44
 if(note>=36 && note<44){
   byte myPin=note-34; // to get a pinnumber between 2 and 9
   digitalWrite(myPin, value);
 }

}


Anyone else seen this?
Logged

France
Offline Offline
Sr. Member
****
Karma: 0
Posts: 262
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

As said before a few times:
[glow]A lot of MIDI devices don't use NOTE OFF messages but NOTE ON with VELOCITY 0.[/glow]
That's the main issue related.
Check that out, add a verification of the velocity before the action to switch to action 0 if the velocity is 0 ! smiley-wink

(and/or connect the two interfaces together and read the raw MIDI to be sure about it.)
« Last Edit: August 11, 2010, 07:43:41 am by tep » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 7
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Oh thanks

sorry I missed your earlier posts.

Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 7
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I can't seem to figure this out. Could you please post a modified version of the code I've been using?

I'm going on a tour with my band and i just changed my Audio/Midi interface and now my "light show" is all mono.

Logged

France
Offline Offline
Sr. Member
****
Karma: 0
Posts: 262
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

No, wait it seems ok, because if the velocity is 0, the velocity is <10 then the light is LOW.
I have no much time for this right now, but I noticed a detail:
Code:
    if ( (action==1)&&(note!=0) ){ // ...and then the velocity
      velocity=incomingByte;
      playNote(note, velocity);
      note=0;
      velocity=0;
      action=2;                  //and not "action=0;" to reinit the value
    }
Otherwise, are you sure polyphony is activated in your software and you didn't miss a setting?
« Last Edit: August 12, 2010, 02:03:35 am by tep » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 1
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi. First of all please excuse my English. For a long time I've being searching for a way to convert MIDI code to plain text. I've found some software but what I really need is to isolate ONLY a list of all Note-On data in the same order they are played. I don't need Velocity, Note-Off Channel Number, Duration, etc. Also need the posibility to transport (change to the other 11 semitones pitch) the whole data. I'm talking about a monodic track (only one voice). For example, to open a MIDI file from Mozart's Piano Sonata first two bars, and to get back this: [C5,E5,G5,B4,C5,D5,C5] But also beguining from [C#5...etc] and [D... etc] and from all the other 11 transposed chromatic steps. This is for Musical Research to found melodic-thematic similarities between within other works from the same or different composers. Could someone give any help to find something near this? I know Peter Van Oostrüm and Günter Nagler's and Go-Minimal software but I can't isolate Note-On data from the rest.
Thank You.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

tep:
Quote
From what I understood it is a different voltage level, so that's a bit more than precaution.
(BTW that's why the 3.3k resistor is 1k if a FTDI is connected.)

I know this thread is a little old, but can anyone explain or point me to some literature why the 3.3k resistor looks like 1k when powered up and how the FTDI relates?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Also the 4N28 optocoupler did not work in any configuration for me.  I could verify the chip itself was working fine using the test circuit on this page [1] and I verified the Arduino Rx worked fine and MIDI signal was fine.  I did finally get things working with the CNY17-4 optocoupler though.

Here is the configuration that ended up working for me:
Arduino Duemilanove connected to Macbook USB
M-Audio Keystation 61es
Schematic in the original post of this thread, substituting CNY17-4 for 4N28

Really strange about the 4N28. No idea why it would not work in this configuration other than some sort of variation between manufacturers [2].

[1]
Test Circuit, see #4:
http://www.technogumbo.com/projects/Learning-to-Use-an-Optocoupler-or-OptoIsolator/

[2] 4N28 by VISHAY SEMICONDUCTOR. I bought mine here:
http://www.newark.com/vishay-semiconductor/4n28/optocoupler/dp/88K1389
Logged

France
Offline Offline
Sr. Member
****
Karma: 0
Posts: 262
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm sorry I can't point you to some literature, but you could have a look at the FTDI chip datasheet and and MIDI specifications.
I've used Motorolas 4N28 an 4N35, the white ones and it works.
Did you try the schematic I did post here?
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1187962258/60#71
The one in the first post seems to work only for the poster, many people have the same problem: No 100k & GND connection on 4N28 pin 1!
Logged

Pages: 1 ... 8 9 [10] 11   Go Up
Jump to: