[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Laser Harp

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 5
Thread images: 1

File: IMG_0588.jpg (2MB, 2448x3264px) Image search: [Google]
IMG_0588.jpg
2MB, 2448x3264px
I'm just finishing up my latest project A midi laser harp based on this design:

http://www.instructables.com/id/Arduino-Laser-Harp-1/

I was wondering if someone here would be able to understand the arduino coding.

I would really like to know how I would be able to change what MIDI notes are being sent out so try different scales and get rid of the octave change in the first and last input.
Please help!
>>
^the harp is upside-down so I can mess with the photo-resistors

here's the code 1 of 2:

/*

MIDI-enabled Laser Harp
SOURCE: http://open-source-energy.org/?topic=1129.0

See: MIDI Technical Specifications
http://en.wikipedia.org/wiki/MIDI#Technical_specifications

*/

#define MIDI_LASER_COUNT 9
#define MIDI_LASER_OCTAVE_DOWN 0
#define MIDI_LASER_OCTAVE_UP 8

short midiCalibrateAmbientLight = 1023;
boolean midiLaserState[MIDI_LASER_COUNT] = {false, false, false, false, false, false, false, false, false};
byte midiNotes[MIDI_LASER_COUNT] = {0, 0, 2, 4, 5, 7, 9, 11, 0};
byte midiOctave = 5;
byte midiPinLaser[MIDI_LASER_COUNT] = {3, 4, 5, 6, 7, 8, 9, 10, 11};
byte midiPinVelocity = A0;
unsigned long midiRateLimit[MIDI_LASER_COUNT] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
unsigned long midiRateLimitThreshold = 35;
unsigned long midiRateLimitThresholdOctave = 70;
byte midiVelocity = 127;

void setup() {
calibrateAmbientLight();
midiInitSerial();
midiInitPins();
midiIntroSong();
}
>>
part 2 of 3 cont:

void loop() {
midiReadLasers();
midiReadVelocity();
}

void calibrateAmbientLight() {
delay(100);
midiCalibrateAmbientLight = analogRead(midiPinVelocity);
}

void midiIntroSong() {
delay(1);
midiSendNoteOn(60, 127);
delay(125);
midiSendNoteOff(60);
midiSendNoteOn(64, 127);
delay(125);
midiSendNoteOff(64);
midiSendNoteOn(67, 127);
delay(125);
midiSendNoteOff(67);
midiSendNoteOn(72, 127);
delay(250);
midiSendNoteOff(72);
midiSendNoteOn(67, 127);
delay(125);
midiSendNoteOff(67);
midiSendNoteOn(72, 127);
delay(500);
midiSendNoteOff(72);
}

boolean midiHandleOctave(byte thePin, boolean theState) {
if (!theState) {return false;}
if ((thePin == MIDI_LASER_OCTAVE_DOWN) && midiOctave == 0) {return false;}
if ((thePin == MIDI_LASER_OCTAVE_UP) && midiOctave == 9) {return false;}
midiOctaveKill();
switch(thePin) {
case MIDI_LASER_OCTAVE_DOWN:
midiOctave--;
break;
case MIDI_LASER_OCTAVE_UP:
midiOctave++;
break;
}
return true;
}

boolean midiHandleRateLimit(byte thePin) {
unsigned long theMillis = millis();
unsigned long theThreshold = 0;
switch (thePin) {
case MIDI_LASER_OCTAVE_DOWN:
case MIDI_LASER_OCTAVE_UP:
theThreshold = midiRateLimitThresholdOctave;
break;
default:
theThreshold = midiRateLimitThreshold;
break;
}
if (theMillis - midiRateLimit[thePin] >= theThreshold) {
midiRateLimit[thePin] = theMillis;
return true;
}
return false;
}
>>
part 3 of 3:

void midiHandleReadLaser(byte thePin, boolean theState) {
if ((midiLaserState[thePin] != theState) && midiHandleRateLimit(thePin)) {
midiLaserState[thePin] = theState;
if ((thePin == MIDI_LASER_OCTAVE_DOWN) || (thePin == MIDI_LASER_OCTAVE_UP)) {
midiHandleOctave(thePin, theState);
} else if (theState) {
midiSendNoteOn(midiNotes[thePin] + (12 *midiOctave), midiVelocity);
} else {
midiSendNoteOff(midiNotes[thePin] + (12 *midiOctave));
}
}
}

void midiInitPins() {
for (byte thePin = 0; thePin < MIDI_LASER_COUNT; thePin++) {
pinMode(midiPinLaser[thePin], INPUT);
}
}

void midiInitSerial() {
Serial.begin(31250);
}

void midiOctaveKill() {
for (byte thePin = 0; thePin < MIDI_LASER_COUNT; thePin++) {
if ((thePin == MIDI_LASER_OCTAVE_DOWN) || (thePin == MIDI_LASER_OCTAVE_UP)) {continue;}
midiHandleReadLaser(thePin, LOW);
}
}

void midiReadLasers() {
for (byte thePin = 0; thePin < MIDI_LASER_COUNT; thePin++) {
midiHandleReadLaser(thePin, digitalRead(midiPinLaser[thePin]));
}
}

void midiReadVelocity() {
midiVelocity = map(analogRead(midiPinVelocity), 0, midiCalibrateAmbientLight, 1, 127);
}

void midiSendCC(byte theCC, byte theValue) {
Serial.write(B10110000);
Serial.write(theCC);
Serial.write(theValue);
}

void midiSendNoteOff(byte theNote) {
Serial.write(B10000000);
Serial.write(theNote);
Serial.write(0);
delay(1);
}

void midiSendNoteOn(byte theNote, byte theVelocity) {
Serial.write(B10010000);
Serial.write(theNote);
Serial.write(theVelocity);
delay(1);
}
>>
>>917291
i dont into programming but reading the code
>byte midiOctave = 5;
maybe but just test and tune altering
other alternative
contact the programmer and ask the source directly
Thread posts: 5
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.