OUR PROJECT
Theremin-like instrument that can play several different scales.
OUR STRUCTURE
This potentiometer doesn't have the smoothest feel in the world but having a big "knob" on it for some reason offsets that and makes it feel gentler than it is. We're thinking to use the potentiometer to change the scales so it would be less frequently used in one particular song.
We're also considering changing the design of the instrument to a vertical interaction that might feel more natural or perhaps angle the sensors in a triangle composition so it's more comfortable. This way it might be more compact and not need the two little antennas on each side for the sensors.
OUR CODE
//Sound project #include <MIDIUSB.h> #include <pitchToNote.h> int baseNote = 60; byte lastnote=0; int trigPin1 = 4; int echoPin1 = 3; //int trigPin2 = 4; //int echoPin2 = 3; int lastDistance = 0; int dx; void setup() { // put your setup code here, to run once: Serial.begin (9600); pinMode(trigPin1, OUTPUT); pinMode(echoPin1, INPUT); // pinMode(trigPin2, OUTPUT); // pinMode(echoPin2, INPUT); } void loop() { // put your main code here, to run repeatedly: byte note = baseNote; long duration1, distance1; digitalWrite(trigPin1, LOW); // Added this line delayMicroseconds(2); // Added this line digitalWrite(trigPin1, HIGH); delayMicroseconds(10); // Added this line digitalWrite(trigPin1, LOW); duration1 = pulseIn(echoPin1, HIGH); distance1 = (duration1) / 29.1; dx = map(distance1, 0, 60, 0, 7); Serial.print ( "Sensor1 "); Serial.print ( distance1); Serial.println("cm"); Serial.print ( " Value"); Serial.println ( dx); delay(1000); if (dx != lastDistance) { delay(5); // debounce delay if (dx==1) { lastnote=note; midiCommand(0x90, note, 127); } if (dx==2) { note = note +2; lastnote=note; midiCommand(0x90, note, 127); } if (dx==3) { note = note +4; lastnote=note; midiCommand(0x90, note, 127); } if (dx==4) { note = note +5; lastnote=note; midiCommand(0x90, note, 127); } if (dx==5) { note = note +7; lastnote=note; midiCommand(0x90, note, 127); } if (dx==6) { note = note +9; lastnote=note; midiCommand(0x90, note, 127); } if (dx==7) { note = note +11; lastnote=note; midiCommand(0x90, note, 127); } else { midiCommand(0x80, lastnote, 0); } } } void midiCommand(byte cmd, byte data1, byte data2) { // First parameter is the event type (top 4 bits of the command byte). // Second parameter is command byte combined with the channel. // Third parameter is the first data byte // Fourth parameter second data byte midiEventPacket_t midiMsg = {cmd >> 4, cmd, data1, data2}; MidiUSB.sendMIDI(midiMsg); }
OUR QUESTIONS
- Can the duration of the note be controlled independently from the sensor's read signal? Meaning, at the moment our sensor reads+plays the notes ASAP but what if we'd like the note to play for a little longer the continue? How do we vary that?
- What kind of control could we use to change the duration of the note? If we want it to be a 1/4, 1/2 of a note or longer.
- If the amplitude and the frequency interfere (sensor signal), can you handle the pitches only with the amplitud?
- In terms of the design of the instrument we're wondering if it would be easier to use it by extending the arms towards the sides (like we have now) or perhaps up and down would be better. Maybe a cylindrical shape would benefit us? Any feedback on this would be appreciated.
コメント