rhoadley.net   music   research   software   blogs

aru    seminars    m&t    critski    focm1a    cmc    circuit bending    mic2b    sensor technology    comp 3    sonic art    major project
youtube    vimeo    facebook


Resources:    Bioacoustics    Jitter    MaxMSP    OSC    Physical    PD       CBHH    sTech    SuperCollider    C/Xcode

sTech Resources:     Home     Blog     Forum     Examples     Projects     Tasks     Tutorials


Sensor Technology Tasks

Arduino 4 Task (MIDI and Basic Audio)

Task 4 Name: Auduino Set: w2i Due: Monday 19th December 2016 Weighting: assessable/recommended (10%) Courses: stech
Prev Task: Connecting the Arduino, MaxMSP and SuperCollider Next Task: Servos
Task Summary All stech tasks

MIDI via Arduino

Physical Set-up. Note the 220 ohm resistor: it is very important a 220 ohm resistor is used, any other value will not work.

/*
MIDI
Language: Wiring/Arduino

Plays MIDI notes from 30 to 90 (F#-0 to F#-5)

*/

char note = 0;    // The MIDI note to be played

void setup()  {
    // Set MIDI baud rate
    Serial.begin(31250);
}

void loop()  {
  // play notes from  30 to 90 (F#-0 to F#-5):
  for (note = 0; note < 127; note ++)  {
    // Note on channel 1 (0x90), some note value (note), middle velocity (0x45):
    noteOn(0x90, note, 0X70);
    delay(10);
    // Note on channel 1 (0x90), some note value (note), silent velocity (0x00):
    noteOn(0x90, note, 0x00);
    delay(100);
  }
}

// Plays a MIDI note.  Doesn't check to see that
// cmd is greater than 127, or that data values are less than 127:

void noteOn(char cmd, char data1, char data2)  {
  Serial.print(cmd, BYTE);
  Serial.print(data1, BYTE);
  Serial.print(data2, BYTE);
}

Another example

/*
MIDI2
Language: Wiring/Arduino

Plays MIDI notes from 30 to 90 (F#-0 to F#-5)

*/

char note = 0;    // The MIDI note to be played
char rnote = 0;  // Random Note

void setup()  {
    // Set MIDI baud rate
    Serial.begin(31250);
}

void loop()  {
  randomSeed(analogRead(0));
  // play notes from  30 to 90 (F#-0 to F#-5):
  for (note = 0; note < 127; note ++)  {
    // Note on channel 1 (0x90), some note value (note), middle velocity (0x45):
    noteOn(0x90, note, 0X70);
    delay(200);
    // Note on channel 1 (0x90), some note value (note), silent velocity (0x00):
    noteOn(0x90, note, 0x00);
    delay(10);
    //
    // Now the random number!
    // return a random number from 50 - 300
    // randNumber = random(50,300);
    rnote = random(0,127);
    noteOn(0x90, rnote, 0X70);
    delay(100);
    noteOn(0x90, rnote, 0X00);
    delay(10);
  }
}

// Plays a MIDI note.  Doesn't check to see that
// cmd is greater than 127, or that data values are less than 127:

void noteOn(char cmd, char data1, char data2)  {
  Serial.print(cmd, BYTE);
  Serial.print(data1, BYTE);
  Serial.print(data2, BYTE);
}

Basic Audio Using a Piezo Disc

Have a look here.


Just in case, here's the latest version of the Arduino to Max Patch

To cover:

This is just a way of communicating via MIDI with another device, through the Arduino...
That
and the other. 

This also has ramifications concerning:

Life, the universe and anything...




to top of page The Task

  • Develop a simple routine using MIDI. You'll need to find a simple MIDI synth for this task. Ebay is sometimes quite useful.

  • Implement it, demonstrate it, photograph it, video it...

Finally

  • Zip or Stuff your patches, demos, etc. into one file called your_student_number_"MIDI" (e.g. 0504335_MIDI.zip or 0504335_MIDI.sit), include a readme with your name and student number and, if necessary, how to use or just open the patch, and submit the whole thing here.

You might also be interested in:

  • Other boards

The Projects

The projects and tasks are designed to help you through the various courses and materials that you'll have to deal with, and also to provide an active and practical element to what could otherwise become a rather dry and technical exercise. Tasks are small exercises - you may be asked to complete one or two per week. Projects are larger and carry a higher percentage of the mark. We will undertake two, three, four or more projects and tasks. The final project is usually an individual choice project, and will be worth significantly more than the others in terms of percentages in your portfolio. We will usually try to set aside a time to perform the projects in a public setting.