0

Untztrument stand-Alone
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Untztrument stand-Alone

by Dario9898 on Tue Dec 06, 2016 1:11 pm

Hi guys!!

I know little about midi, now I'm starting to get interested.
For a school project I would like to make an Untztrument but stand-alone so I don't need computer.
I thought I put together 1 or more trellis and then, for the instrument, 1 mp3 music maker shield.
I bought both the object and I tried to connect them with each other but whitout results (for the program I used the simple examples of the trellis and Midi so when i pressed a button the shield came a sound). Someone can give me some advice??

Dario9898
 
Posts: 8
Joined: Tue Dec 06, 2016 12:47 pm

Re: Untztrument stand-Alone

by adafruit_support_rick on Thu Dec 08, 2016 9:31 am

I don't understand how you have the untztrument connected to the music maker shield. Can you post some circuit diagrams and/or pictures?

adafruit_support_rick
 
Posts: 34137
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Untztrument stand-Alone

by Dario9898 on Sat Dec 10, 2016 10:37 am

I badly explained myself. I have only a trellis, a music maker shield and arduino . The music maker has MIDI mode so I want use this mode to make music. For exemple when I press a button of Trellis, come out a sound from the music maker. It's possible??

Dario9898
 
Posts: 8
Joined: Tue Dec 06, 2016 12:47 pm

Re: Untztrument stand-Alone

by adafruit_support_rick on Sat Dec 10, 2016 11:32 am

I think so. Connect the trellis to the arduino via I2C. Read the trellis with the arduino. When you detect a button press on the trellis, then send a midi command to the music maker. We don't have any example code for doing this. But you can look at the trellis example code to see how to read the buttons. Looks at the music maker example code to see how to send midi commands.

adafruit_support_rick
 
Posts: 34137
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Untztrument stand-Alone

by Dario9898 on Mon Dec 12, 2016 3:26 pm

Ok, I try and now it works.
Now I have other 2 simple (I hope) questions:
1 Can I play different instrument at the same time? (For example a button play the guitar and an other buttun play the piano)
2 How I can change the parameters of volume and the effect as the reverb or the tonality? (If it is possible)

Dario9898
 
Posts: 8
Joined: Tue Dec 06, 2016 12:47 pm

Re: Untztrument stand-Alone

by adafruit_support_rick on Tue Dec 13, 2016 9:58 am

The chip supports 16 channels. You can set the instrument and volume for each channel.

See the datasheet for the instrument sounds available. There are three banks of instruments. One for melodic instruments, two banks for percussion. In my experience, all the percussion instruments sound the same.

Look at the player_miditest example from the library. It shows how to configure a channel for bank, instrument and volume.

See page 31 and 32 of the datasheet for more details
http://www.vlsi.fi/fileadmin/datasheets/vs1053.pdf

There are reverb, sostenuto, and other effects. You set them by writing to the same channel message as you write to to set the bank.

adafruit_support_rick
 
Posts: 34137
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Untztrument stand-Alone

by Dario9898 on Tue Dec 13, 2016 11:32 am

Ok, thank you very much!!

Dario9898
 
Posts: 8
Joined: Tue Dec 06, 2016 12:47 pm

Re: Untztrument stand-Alone

by Dario9898 on Sun Dec 18, 2016 2:26 pm

I tried to do as you told me, but I can't understand how to define the different effects. Can you write me the code to define the effects?? And where, I have to write the parameter to change the effects??

Dario9898
 
Posts: 8
Joined: Tue Dec 06, 2016 12:47 pm

Re: Untztrument stand-Alone

by adafruit_support_rick on Sun Dec 18, 2016 4:34 pm

I added three functions to the example sketch. midiSetChannelReverbLevel, midiSetChannelReverbDecay, and midiSetChannelSostenuto. I'm not sure what the argument to Sostenuto should be - the datasheet doesn't say. But you can play with different values to see what it does:
Code: Select all | TOGGLE FULL SIZE
/***************************************************
  This is an example for the Adafruit VS1053 Codec Breakout

  Designed specifically to work with the Adafruit VS1053 Codec Breakout
  ----> https://www.adafruit.com/products/1381

  Adafruit invests time and resources providing this open source code,
  please support Adafruit and open-source hardware by purchasing
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries. 
  BSD license, all text above must be included in any redistribution
 ****************************************************/

#include <SoftwareSerial.h>

// define the pins used
#define VS1053_RX  2 // This is the pin that connects to the RX pin on VS1053

#define VS1053_RESET 9 // This is the pin that connects to the RESET pin on VS1053
// If you have the Music Maker shield, you don't need to connect the RESET pin!

// If you're using the VS1053 breakout:
// Don't forget to connect the GPIO #0 to GROUND and GPIO #1 pin to 3.3V
// If you're using the Music Maker shield:
// Don't forget to connect the GPIO #1 pin to 3.3V and the RX pin to digital #2

// See http://www.vlsi.fi/fileadmin/datasheets/vs1053.pdf Pg 31
#define VS1053_BANK_DEFAULT 0x00
#define VS1053_BANK_DRUMS1 0x78
#define VS1053_BANK_DRUMS2 0x7F
#define VS1053_BANK_MELODY 0x79

// See http://www.vlsi.fi/fileadmin/datasheets/vs1053.pdf Pg 32 for more!
#define VS1053_GM1_OCARINA 80

#define MIDI_NOTE_ON  0x90
#define MIDI_NOTE_OFF 0x80
#define MIDI_CHAN_MSG 0xB0
#define MIDI_CHAN_BANK 0x00
#define MIDI_CHAN_VOLUME 0x07
#define MIDI_CHAN_PROGRAM 0xC0
#define MIDI_CHAN_REVERB_LEVEL 0x5b
#define MIDI_CHAN_REVERB_DECAY 0x0c
#define MIDI_CHAN_SUSTENUTO 0x42

SoftwareSerial VS1053_MIDI(0, 2); // TX only, do not use the 'rx' side
// on a Mega/Leonardo you may have to change the pin to one that
// software serial support uses OR use a hardware serial port!

void setup() {
  Serial.begin(9600);
  Serial.println("VS1053 MIDI test");
 
  VS1053_MIDI.begin(31250); // MIDI uses a 'strange baud rate'
 
  pinMode(VS1053_RESET, OUTPUT);
  digitalWrite(VS1053_RESET, LOW);
  delay(10);
  digitalWrite(VS1053_RESET, HIGH);
  delay(10);
 
  midiSetChannelBank(0, VS1053_BANK_MELODY);
  midiSetInstrument(0, VS1053_GM1_OCARINA);
  midiSetChannelVolume(0, 127);
  midiSetChannelReverbLevel(0, 64);
  midiSetChannelReverbDecay(0, 32);
}

void loop() { 
  for (uint8_t i=60; i<69; i++) {
    midiNoteOn(0, i, 127);
    delay(100);
    midiNoteOff(0, i, 127);
  }
 
  delay(1000);
}

void midiSetInstrument(uint8_t chan, uint8_t inst) {
  if (chan > 15) return;
  inst --; // page 32 has instruments starting with 1 not 0 :(
  if (inst > 127) return;
 
  VS1053_MIDI.write(MIDI_CHAN_PROGRAM | chan); 
  VS1053_MIDI.write(inst);
}


void midiSetChannelVolume(uint8_t chan, uint8_t vol) {
  if (chan > 15) return;
  if (vol > 127) return;
 
  VS1053_MIDI.write(MIDI_CHAN_MSG | chan);
  VS1053_MIDI.write(MIDI_CHAN_VOLUME);
  VS1053_MIDI.write(vol);
}

void midiSetChannelReverbLevel(uint8_t chan, uint8_t level) {
  if (chan > 15) return;
  if (level > 127) return;
 
  VS1053_MIDI.write(MIDI_CHAN_MSG | chan);
  VS1053_MIDI.write(MIDI_CHAN_REVERB_LEVEL);
  VS1053_MIDI.write(level);
}

void midiSetChannelReverbDecay(uint8_t chan, uint8_t decay) {
  if (chan > 15) return;
  if (decay > 127) return;
 
  VS1053_MIDI.write(MIDI_CHAN_MSG | chan);
  VS1053_MIDI.write(MIDI_CHAN_REVERB_DECAY);
  VS1053_MIDI.write(decay);
}

void midiSetChannelSustenuto(uint8_t chan, uint8_t arg) {
  if (chan > 15) return;
  if (arg > 127) return;
 
  VS1053_MIDI.write(MIDI_CHAN_MSG | chan);
  VS1053_MIDI.write(MIDI_CHAN_SUSTENUTO);
  VS1053_MIDI.write(arg);
}

void midiSetChannelBank(uint8_t chan, uint8_t bank) {
  if (chan > 15) return;
  if (bank > 127) return;
 
  VS1053_MIDI.write(MIDI_CHAN_MSG | chan);
  VS1053_MIDI.write((uint8_t)MIDI_CHAN_BANK);
  VS1053_MIDI.write(bank);
}

void midiNoteOn(uint8_t chan, uint8_t n, uint8_t vel) {
  if (chan > 15) return;
  if (n > 127) return;
  if (vel > 127) return;
 
  VS1053_MIDI.write(MIDI_NOTE_ON | chan);
  VS1053_MIDI.write(n);
  VS1053_MIDI.write(vel);
}

void midiNoteOff(uint8_t chan, uint8_t n, uint8_t vel) {
  if (chan > 15) return;
  if (n > 127) return;
  if (vel > 127) return;
 
  VS1053_MIDI.write(MIDI_NOTE_OFF | chan);
  VS1053_MIDI.write(n);
  VS1053_MIDI.write(vel);
}

adafruit_support_rick
 
Posts: 34137
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Untztrument stand-Alone

by Dario9898 on Sun Dec 18, 2016 4:40 pm

Thank you very much !!

Dario9898
 
Posts: 8
Joined: Tue Dec 06, 2016 12:47 pm

Re: Untztrument stand-Alone

by Dario9898 on Tue Feb 14, 2017 12:28 pm

Hi!!
I have a new question about my project "untztrument stand-alone". If I want to save a midi message (or more as a full music) that I produce with the music shield in a micro sd that I have in the same music shield it's possible to do this operation?? And if yes can you write me an example to do this operation??

Dario9898
 
Posts: 8
Joined: Tue Dec 06, 2016 12:47 pm

Re: Untztrument stand-Alone

by adafruit_support_rick on Tue Feb 14, 2017 6:39 pm

You can write midi instructions to an SD card, and then play them back through the music shield, but I can't write your sketch for you.

adafruit_support_rick
 
Posts: 34137
Joined: Tue Mar 15, 2011 11:42 am
Location: Buffalo, NY

Re: Untztrument stand-Alone

by Dario9898 on Wed Feb 15, 2017 2:06 am

Ok thanks anyway!

Dario9898
 
Posts: 8
Joined: Tue Dec 06, 2016 12:47 pm

Please be positive and constructive with your questions and comments.