Proto MIDI breath-control
proposed by Prof.Satoshi Nishimura image00 / Jichi Med Univ(JAPAN)

Specs: Signals of air-flow sensors from windsynthe are used for keyboard play.

E-mail: If interested (snishi-tky(a-mark)ninus.ocn.ne.jp ) image00

Back to top image00
Movie: how it runs image00



		

			int inch=0;  //by naturalserial,from windsynthe  & to sounds module

  

			void setup() 
			{
			 
			  //set PINS
			  
			
			  //start MIDI in/out
			  Serial.begin(31250);
			  
			  for (int i=0; i<95;i++)
			  {
				Serial.write(byte(0x80+inch));
				Serial.write(byte(0x60-i));
				Serial.write(byte(0x00));
				delay(10);
			  }
			  
			  for (int i=0; i<30;i++)
			  {
				Serial.write(byte(0x90+inch));  
				Serial.write(byte(0x60-i));
				Serial.write(byte(0x7f));
				delay(80);
				Serial.write(byte(0x80+inch));
				Serial.write(byte(0x60-i));
				Serial.write(byte(0x00));
				delay(10);
			  }
			
			  
			}
			
			unsigned long last_time=millis();
			int lastbreath=0;
			void loop() 
			
			{
			 
			  // check time
			  unsigned long el_time=millis();
			  int difftime = -last_time +el_time;
			  last_time = el_time;
			
			  // clear unknown data in 10sec
			  if(el_time % 10000 == 0)
			  {
				for (int i=0;i<1;i++)
				{
				  if (Serial.available() > 0)
				  {
					   int inNULL = Serial.read();
				  }
				  else
				  {
					   i++;
				  }   
				}
			  }
			
			
			
			  if (Serial.available() > 0)
			  {
				   int inByte1 = Serial.read(); 
				   if(inByte1 == 0x90+inch || inByte1==0x80+inch || inByte1==0x90  || inByte1 == 176)
				   {
					for (int i=0; i<1000; i++)
					{
						if (Serial.available() > 1)
						{
							i=3000;
							int inByte2 = Serial.read();
							int inByte3 = Serial.read();
				
					//NOTEON
						  if (inByte1 == (0x90+inch)&& inByte2!=97)
						  {
							 Serial.write(0x90);
							 Serial.write(inByte2);
							byte out=(byte)(inByte3*0.6);
							Serial.write(out);
						  }
						  else if (inByte1 == (0x90+inch)&& inByte2==97) //breath sensing
						  {
							Serial.write(0xB0);
							Serial.write(2);
							byte out=(byte)(inByte3);
							Serial.write(out);
						  }
						   else if (inByte1 == 176&& inByte2==2) //breath sensing
						  {
							Serial.write(0xB0);
							Serial.write(2);
							byte out=(byte)(inByte3);
							Serial.write(out);
						  }
						  else if (inByte1 == (0x80+inch))
						  {
							 Serial.write(0x80);
							 Serial.write(inByte2);
							 Serial.write(inByte3);
						  }
						}
					}
				   }
			  }
			}