openpipe with fluxamasynth

Hi again! :slight_smile: :slight_smile: :slight_smile:

Remember my crying about the fluxamasynth bagpipe....well I am almost done with that project and it will be very simple fix
what I have for you all.

The openpipe works with the fluxamasynth, I programed the instrument to be set as 109 (bagpipe) but when I do some notes
it changes to 0 (piano).

this is what I think is the problem.

[
//byte note = 0; //The MIDI note value to be played
byte resetMIDI = 4; //Tied to VS1053 Reset line
byte ledPin = 13; //MIDI traffic inidicator
int instrument = 0;
/code]

the code was made for a music instrument shield from sparkfun dot com.
I had to change the rx (1) and tx (4) numbers for this code to get sound out of the fluxamasynth.
I think the problem lies in the VS1053 Reset line.

this is what I think is the problem.

Nothing wrong with that code. Mind you it doesn't do anything either so that is little surprise.

If you want help you have to post all your code.

The code is too long for the forum.. :grin:

I will give you a link to the code.

here is a better link.....sorry

This code is wrong:-

int note_on(int note, int vel){
    t_midiMsg midiMsg;
    
    midiMsg.msg.command = MIDI_COMMAND_NOTE_ON;
    midiMsg.msg.channel = MIDI_DEFAULT_CHANNEL;
    midiMsg.msg.data2 = note;
    midiMsg.msg.data3 = vel;	/* Velocity */
    
    Serial.write(midiMsg.raw, sizeof(midiMsg));
}

Because you are sending 4 bytes of data instead of three.
The midi channel should be merged with the midi command not sent as a separate byte.
This applies to all the functions you do like this.

Why do you have this method of sending MIDI when you have a perfectly good set of functions to do this in the sketch?

????

I don't know what you mean.

should I get rid of

midiMsg.msg.data3 = vel;	 /* Velocity */

Or program the code to handle it.

How much of this code do I have to change?

Oh I see merge command with channel..... but how?

Maybe every part where command and channel is piece it two gether. I still don't know how.

Oh I see merge command with channel..... but how?

By using the bit wise OR operation, then do not output all that structure but the first two bytes ORed together followed by the last two. Do that for all the routines that use that structure
I am guessing you did not write that code, point is do you understand it?

I didn't write the code but i have lillte or no understanding of the code.

Then look at every function that ends in

Serial.write(midiMsg.raw, sizeof(midiMsg));

And delete the whole of the function.

Any calls to these deleted functions should be replaced to the other set of midi out functions you have in that sketch.

Code:

Serial.write(midiMsg.raw, sizeof(midiMsg));

Then look at every function that ends in

did so... still don't know how to add a function that will work. I know you want me to learn this my self.
Can you give me a link of functions that I can use?

Grumpy_Mike:
Then look at every function that ends in

Serial.write(midiMsg.raw, sizeof(midiMsg));

And delete the whole of the function.

Any calls to these deleted functions should be replaced to the other set of midi out functions you have in that sketch.

None of those three errant functions are actually being called in the sketch anyway...

[code   uint8_t raw[4];
} t_midiMsg;
]

should I delete this to?

the question really is, should I add any thing?

Serial.write(midiMsg.raw, sizeof(midiMsg));

every part where this was I deleted it and it still didn't work.

Trazman001:
should I delete this to?

the question really is, should I add any thing?

I don't think that will matter. Also, the instrument=0 will not matter because it is not being used anywhere either.

Sorry, I don't know anything about the shield or Midi.

And, what is your thinking about the "VS1053 reset line"?

Cheers,
John

grumpy mike

If you would please show me the right code to use. :wink:

this code was ment for the spark fun music instrument code.

These functions will work:-

void noteOn(byte channel, byte note, byte attack_velocity) {
  talkMIDI( (0x90 | channel), note, attack_velocity);
}

//Send a MIDI note-off message. Like releasing a piano key
void noteOff(byte channel, byte note, byte release_velocity) {
  talkMIDI( (0x80 | channel), note, release_velocity);
}

void soundsOff(byte channel){
  talkMIDI( (MIDI_COMMAND_SOUNDS_OFF | channel), 120, 0);
}

These functions will not work:-

int MIDI_sounds_off(void){
   t_midiMsg midiMsg;
   midiMsg.msg.command = MIDI_COMMAND_SOUNDS_OFF;
   midiMsg.msg.channel = MIDI_DEFAULT_CHANNEL;
   midiMsg.msg.data2 = 120;
   midiMsg.msg.data3 = 0;	/* Velocity */
   
   Serial.write(midiMsg.raw, sizeof(midiMsg));
}

int note_on(int note, int vel){
    t_midiMsg midiMsg;
    
    midiMsg.msg.command = MIDI_COMMAND_NOTE_ON;
    midiMsg.msg.channel = MIDI_DEFAULT_CHANNEL;
    midiMsg.msg.data2 = note;
    midiMsg.msg.data3 = vel;	/* Velocity */
    
    Serial.write(midiMsg.raw, sizeof(midiMsg));
}

int note_off(int note, int vel){
    t_midiMsg midiMsg;
    
    midiMsg.msg.command = MIDI_COMMAND_NOTE_OFF;
    midiMsg.msg.channel = MIDI_DEFAULT_CHANNEL;
    midiMsg.msg.data2 = note;
    midiMsg.msg.data3 = vel;	/* Velocity */
    
    Serial.write(midiMsg.raw, sizeof(midiMsg));
}

Replace calls to the latter with the former with the appropriate calling parameters.

will some of these work??

void noteOn(byte channel, byte pitch, byte velocity);
  void noteOff(byte channel, byte pitch);
  void programChange (byte bank, byte channel, byte value);
  void pitchBend(byte channel, int value);
  void pitchBendRange(byte channel, byte value);
  void midiReset();
  void setChannelVolume(byte channel, byte level);
  void allNotesOff(byte channel);
  void setMasterVolume(byte level);
  void setReverb(byte channel, byte program, byte level, byte delayFeedback);
  void setChorus(byte channel, byte program, byte level, byte feedback, byte chorusDelay);

Please please pretty please. tell me what to enter.

Are they from the library provided by moderndevice? Then they are supposed to...

Why don't you load the example sketch that comes with the library to find out?

instead of

int MIDI_sounds_off(void){
   t_midiMsg midiMsg;
   midiMsg.msg.command = MIDI_COMMAND_SOUNDS_OFF;
   midiMsg.msg.channel = MIDI_DEFAULT_CHANNEL;
   midiMsg.msg.data2   = 120;
   midiMsg.msg.data3   = 0;	/* Velocity */
   
   Serial.write(midiMsg.raw, sizeof(midiMsg));
}

int note_on(int note, int vel){
    t_midiMsg midiMsg;
    
    midiMsg.msg.command = MIDI_COMMAND_NOTE_ON;
    midiMsg.msg.channel = MIDI_DEFAULT_CHANNEL;
    midiMsg.msg.data2   = note;
    midiMsg.msg.data3   = vel;	/* Velocity */
    
    Serial.write(midiMsg.raw, sizeof(midiMsg));
}

int note_off(int note, int vel){
    t_midiMsg midiMsg;
    
    midiMsg.msg.command = MIDI_COMMAND_NOTE_OFF;
    midiMsg.msg.channel = MIDI_DEFAULT_CHANNEL;
    midiMsg.msg.data2   = note;
    midiMsg.msg.data3   = vel;	/* Velocity */
    
    Serial.write(midiMsg.raw, sizeof(midiMsg));
}

maybe just

void noteOn(byte channel, byte pitch, byte velocity);
  void noteOff(byte channel, byte pitch);
void midiReset();

think it will work?

Trazman001:
think it will work?

Maybe!

In this code I see methods for Fluxamasynth libraries but no relation to the code I am using

#include "Fluxamasynth.h" //will I need this?

Fluxamasynth synth; //will I need this?

#define c3 48                // define our notes to their midi values
#define e3 52
#define g3 55
#define c4 60

void setup() {
  Serial.begin(31250);
  synth.programChange(0, 0, 40);
  synth.programChange(0, 1, 0);
}

void loop()
{
  synth.noteOn(0, c4, 127);  // play 1 note (C4) on channel 0

  delay(1000);
  synth.noteOff(0, c4);

  synth.noteOn(1, c3, 127);
  synth.noteOn(1, e3, 127);  // play 3 notes (C3, E3, G3) on channel 1
  synth.noteOn(1, g3, 127);

  delay(1000);
  synth.noteOff(1, c3);
  synth.noteOff(1, e3);
  synth.noteOff(1, g3);
}

and does these work with synth.noteOn and synth.noteOff

#define MIDI_COMMAND_NOTE_OFF       0x80
#define MIDI_COMMAND_NOTE_ON        0x90
#define MIDI_COMMAND_SOUNDS_OFF     0xB0//I see no methods for these.

And This...how do I set it up as a instrumtent with out playing notes automaticaly and keeping the parameters.

synth.noteOn(0, c4, 127);  // play 1 note (C4) on channel 0

and does these work with synth.noteOn and synth.noteOff

Those are the bytes that consist of the MIDI messages, they are just ways of referring to those messages by name not number.

how do I set it up as a instrumtent with out playing notes automaticaly and keeping the parameters.

I have no idea what this means and I suspect you do not either.
What do you mean by "set up and instrument". Do you mean voice change? That is sent with a ProgramChange message.

Basically I don't think you know enough about MIDI to do what you want to do. You seem to be thrashing about trying to do things you do not understand by collecting together code you have found and hopping it will work. Then you ask questions but you are incapable of understanding the answers. It is like learning how to ask for directions to the train station in a foreign language with out learning enough of that language to understand the answer.

You need to read about the fundamentals of MIDI and MIDI messages. A good point of reference is here:-

Then start writing your code, not some code you found, very simply at first, adding a small bit at a time and testing it as you go. Learn to understand what you are doing.