【EvilMK】“Orchid”像样的Arduino架子鼓
来参加上海创客嘉年华的伙伴们有没有看到这个作品:lol几位小伙伴问我开不开源,那不是必须的嘛~制作过程送上!
不好意西啦,交这个作业迟了点,都一个多月了...真的抱歉:shutup:
http://player.youku.com/player.php/sid/XMTMxNjgyMTU0MA==/v.swf
送上活动时候的照片(明和电机的社长大大真的好萌:loveliness:)
/*EvilMaker Orchid (Opensource) 2015 v1.00-d
by Virtualwiz
*/
void midiSend (int cmd, int pitch, int velocity) {
Serial.write(cmd);
Serial.write(pitch);
Serial.write(velocity);
}
const byte buzzer=50;
//Serial to MIDI or Native MIDI?
boolean debug_mode=true;
const unsigned char kick=36;
const unsigned char snare=38;
const unsigned char tom_high=50;
const unsigned char tom_low=45;
const unsigned char tom_bass=41;
const unsigned char crash_left=49;
const unsigned char crash_right=57;
const unsigned char hat_open=51; //46
const unsigned char hat_close=42;
char adc_channel ={
'A0','A1','A2','A3','A4','A5','A6'
};
void setup() {
pinMode(buzzer,OUTPUT);
pinMode(7,OUTPUT);
pinMode(6,INPUT);
pinMode(3,INPUT);
digitalWrite(3,HIGH);
digitalWrite(6,HIGH);
//3 is for Kick and 6 is for hi-hat
//Startup tone
tone(buzzer,1397,130);
delay(130);
tone(buzzer,1568,130);
delay(130);
tone(buzzer,1760,150);
delay(1500);
pinMode(7,OUTPUT);
if(debug_mode)
{
Serial.begin(115200);//Debug mode baud rate
tone(buzzer,1397,120);
delay(300);
tone(buzzer,1397,120);
delay(1000);
}
else
{
Serial.begin(31250);//MIDI baud rate
tone(buzzer,1397,120);
delay(1000);
}
tone(buzzer,1397,300);
delay(1000);
}
unsigned char adc_sample;
boolean kick_trig_flag=false;//Is Kick already triggered?
//IMPORTANT!
//Adjust this if your pads are dull or too sensitive
//{crash,hat,snare,tom_bass,crash_right,tom_high,tom_low}
unsigned char adc_cutoff=//minimum strength
{
3, 3, 10, 7, 3, 3, 3};
unsigned char adc_limit= //maximum strength
{
40, 10, 30, 50, 40, 10, 10};
void loop() {
digitalWrite(7,HIGH);
for(byte count=0;count<=6;count++)
{
adc_sample=map(analogRead(adc_channel),0,1023,0,254);
}
//Here is a strange problem
//0 and 6 can't get their correct value if following code was not written
adc_sample=map(analogRead(A6),0,1023,0,254);
adc_sample=map(analogRead(A0),0,1023,0,254);
//Pls contant me if you know why,thx
digitalWrite(7,LOW);
if(adc_sample>=adc_cutoff)
{
if(adc_sample>=adc_limit)
adc_sample=adc_limit;
midiSend(0x99,crash_left,map(adc_sample,adc_cutoff,adc_limit,0x00,0x7f));
// Serial.print("\t");
//Serial.println(adc_sample);
}
if(adc_sample>=adc_cutoff)
{
if(adc_sample>=adc_limit)
adc_sample=adc_limit;
if(digitalRead(6)==HIGH)
midiSend(0x99,hat_open,map(adc_sample,adc_cutoff,adc_limit,0x00,0x7f));
else
midiSend(0x99,hat_close,map(adc_sample,adc_cutoff,adc_limit,0x00,0x7f));
}
if(adc_sample>=adc_cutoff)
{
if(adc_sample>=adc_limit)
adc_sample=adc_limit;
midiSend(0x99,snare,map(adc_sample,adc_cutoff,adc_limit,0x00,0x7f));
delay(13); //sorry that my snare pad is too bouncy
}
if(adc_sample>=adc_cutoff)
{
if(adc_sample>=adc_limit)
adc_sample=adc_limit;
midiSend(0x99,tom_bass,map(adc_sample,adc_cutoff,adc_limit,0x00,0x7f));
}
if(adc_sample>=adc_cutoff)
{
if(adc_sample>=adc_limit)
adc_sample=adc_limit;
midiSend(0x99,crash_right,map(adc_sample,adc_cutoff,adc_limit,0x00,0x7f));
}
if(adc_sample>=adc_cutoff)
{
if(adc_sample>=adc_limit)
adc_sample=adc_limit;
midiSend(0x99,tom_high,map(adc_sample,adc_cutoff,adc_limit,0x00,0x7f));
}
if(adc_sample>=adc_cutoff)
{
if(adc_sample>=adc_limit)
adc_sample=adc_limit;
midiSend(0x99,tom_low,map(adc_sample,adc_cutoff,adc_limit,0x00,0x7f));
}
if(digitalRead(3)==HIGH)
{
kick_trig_flag=false;
}
if(digitalRead(3)==LOW)
{
if(kick_trig_flag==false)
{
midiSend(0x99,kick,0x7f);
kick_trig_flag=true;
}
}
delay(5);//This is the total sensitivity for all the pads
}
/*ADC Test
int val;
for(int i = 0; i < 8; i++) {
val = analogRead(i);
Serial.print("CH");
Serial.print(i);
Serial.print("\t Value=");
Serial.print(val);
Serial.print("\n");
delay(20);
}
Serial.print("\n");
delay(1000);
*/
/*MIDI Send Test
//This is a simple loop for you to check your MIDI bridge and synthesizer.
midiSend(0x99,hat_close, 0x45);
midiSend(0x99,kick, 0x45);
delay(300);
midiSend(0x99,hat_close, 0x45);
delay(300);
midiSend(0x99,hat_close, 0x45);
midiSend(0x99,snare, 0x45);
delay(300);
midiSend(0x99,hat_close, 0x45);
midiSend(0x99,kick, 0x45);
delay(300);
midiSend(0x99,hat_close, 0x45);
midiSend(0x99,kick, 0x45);
delay(300);
midiSend(0x99,hat_close, 0x45);
delay(300);
midiSend(0x99,hat_close, 0x45);
midiSend(0x99,snare, 0x45);
delay(300);
midiSend(0x99,hat_close, 0x45);
delay(300);
*/
可以选择串口转MIDI(9600bps)或真MIDI(31250bps)两种波特率,看你怎么方便连接了~
各个板子的灵敏度在程序中也可以调节。
连接件要打印一下,能装个M10的螺帽进去就行。这个难不倒伙伴们吧:lol
然后装在木板上,自攻螺丝拧进去
为了防止敲击的时候产生“剁馅”的声音,木板的正面要贴一层橡胶(P.S.我用的木板太厚了,大家要是想做可以用薄一点的,8mm就行)
这是压电陶瓷,很便宜,用于测出震动大小。焊接的时候要小心,需要助焊剂
因为Windows有MIDI延迟的Bug,实时性相当不好(有专业声卡除外~)
Linux和Mac都没有这个问题
如果用Linux,可能需要这些软件(根据需要大胆配置~多种组合方案)
统统是免费或者开源软件哦:$
jackd
qjackctl //jack的GUI
fluidsynth
qsynth //fluidsynth的GUI
fluid-soundfont-gm //音色库,内有多种鼓的声音
拿快递很开心,直径28的有机玻璃管,金属三通,丝杆,螺帽,木(cai)板
管子很脆,钻孔要小心(拖鞋不是我的,请无视:curse:)
略微设计一下,架子完工~这个结构仅供参考
电子设备,要是328p系列的arduino模拟口不够用,建议用Mega。(我最终用的就是)
装好的效果
本帖最后由 virtualwiz 于 2015-11-3 17:59 编辑
剩下的就是自由发挥了:D,想怎么玩都可以
碉堡了6666666666666 去的时候看到了。牛人一枚 我也要做一个~{:5_172:} 32个赞{:5_185:} 好赞~~~~顶一个先。。。。
后面仔细看了一下,原理没怎么讲,一般人是看不明白的,可能只多放了些照片。。。。。希望稍微具体些,就更完美了~~~~
视频也不错的~~~ 好期待好期待!!!!蘑菇云来一套~~~来一套~~~~哟哟~切克闹!! 又会玩音乐、又会造乐器、又长的帅~~简直就是:完!美!(请自行脑补金星老师动作) luna 发表于 2015-11-5 14:49
又会玩音乐、又会造乐器、又长的帅~~简直就是:完!美!(请自行脑补金星老师动作) ...
哈哈哈,这算是表扬他吗? 碉堡了6666666666666 arduino架子鼓,简直帅气! MIDI那部分接线怎么弄啊 都看不到 请赐教啊 你好能给我一分电路图吗 ?
550316019@QQ.COM fluidsynth is difficult.tell me how to use it please.:'( Chinese without Chinese.:o
页:
[1]
2