From e3d16c3798aea007efaf6e956390d1e6b5da5774 Mon Sep 17 00:00:00 2001 From: neingeist Date: Sun, 4 Apr 2010 17:37:39 +0200 Subject: [PATCH 1/3] comment macro, remove semicolon --- projekte/protothreads/example.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projekte/protothreads/example.c b/projekte/protothreads/example.c index 82844a4..366d407 100644 --- a/projekte/protothreads/example.c +++ b/projekte/protothreads/example.c @@ -7,12 +7,12 @@ #include "timer/clock.h" #include "timer/timer.h" -/* TIMER_DELAY macro for convenience */ +/* TIMER_DELAY macro for convenience, do { } while(0) is just a macro trick */ #define TIMER_DELAY(pt, timer, t) \ do { \ timer_set(&timer, t); \ PT_WAIT_UNTIL(pt, timer_expired(&timer)); \ - } while(0); + } while(0) /* Two timers for the two protothreads. */ static struct timer timer1, timer2; From 72aefc8c729fef43fb53fb15d5da7262d3eadc36 Mon Sep 17 00:00:00 2001 From: neingeist Date: Mon, 5 Apr 2010 20:44:40 +0200 Subject: [PATCH 2/3] actually use MAGIC_BREATH --- projekte/soundz/arpeggio/arpeggio.pde | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/projekte/soundz/arpeggio/arpeggio.pde b/projekte/soundz/arpeggio/arpeggio.pde index 6ceb64a..862d18b 100644 --- a/projekte/soundz/arpeggio/arpeggio.pde +++ b/projekte/soundz/arpeggio/arpeggio.pde @@ -93,12 +93,12 @@ void arpeggio_play(int32_t note, uint32_t len) { // clock tick is 1s/18.2 == 54ms #define MAGIC_CLOCK_TICK 54 #define MAGIC_DELAY_FACTOR 400 // well, should be 1000 us?! - #define MAGIC_BREATH 50 _delay_us(MAGIC_DELAY_FACTOR*(len*MAGIC_CLOCK_TICK/10)); // breath curNote=REST; - _delay_us(50); + #define MAGIC_BREATH 50 + _delay_us(MAGIC_BREATH); } void arpeggio(int32_t n1, int32_t n2, int32_t n3, int32_t len) { From 8b50243dada2a5458958da143dff94957c4ec74c Mon Sep 17 00:00:00 2001 From: xeno Date: Tue, 6 Apr 2010 22:21:52 +0200 Subject: [PATCH 3/3] =?UTF-8?q?xeno=20macht=20L=C3=A4rm?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- projekte/soundz/quak/quak.pde | 53 +++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 projekte/soundz/quak/quak.pde diff --git a/projekte/soundz/quak/quak.pde b/projekte/soundz/quak/quak.pde new file mode 100644 index 0000000..b9000ed --- /dev/null +++ b/projekte/soundz/quak/quak.pde @@ -0,0 +1,53 @@ +byte foo; +int bar; +byte mul; +byte cnt; +float wow; +boolean b; +int inv; + +#define WOW_FACTOR 512 +#define WOW_LIMIT 4 + +void setup() { + pinMode(8, OUTPUT); + cnt = 0; + mul = 1; + wow = WOW_FACTOR; + inv = 1; +} + + + +void loop() { + + if( cnt == 0 ) { + mul = random(6)+1; + cnt = 25; + } + + cnt--; + + foo = random(5*mul)+2; + + for(bar = 0; bar < (255-(foo*20)); bar++) { + + + if( inv == 1 ) + wow /= 2; + else + wow *= 2; + + if( wow < WOW_LIMIT || wow > WOW_FACTOR ) { + inv = inv == 1 ? -1 : 1; + } + + digitalWrite(8, b = !b); + delayMicroseconds((WOW_FACTOR+(wow*inv))*foo+(bar*2*b)); + + // NOISE + if( random(10) == 0 ) { + digitalWrite(8, b = !b); delayMicroseconds(4500); digitalWrite(8, b = !b); + } + } +}