Upgrade to Pro — share decks privately, control downloads, hide ads and more …

SSAW14 第2回 - センサーでMozziをコントロール

SSAW14 第2回 - センサーでMozziをコントロール

Atsushi Tadokoro

April 19, 2014
Tweet

More Decks by Atsushi Tadokoro

Other Decks in Technology

Transcript

  1. #include <MozziGuts.h> #include <Oscil.h> #include <tables/sin2048_int8.h> ! Oscil <2048, AUDIO_RATE>

    aSin(SIN2048_DATA); ! void setup(){ startMozzi(CONTROL_RATE); aSin.setFreq(440); } ! void updateControl(){ } ! int updateAudio(){ return aSin.next(); } ! void loop(){ audioHook(); } .P[[Jϓϩάϥϛϯά ɺ͸͡ΊͷҰา ‣ αϯϓϧ4JO೾Λੜ੒͢ΔϓϩάϥϜ
  2. #include <MozziGuts.h> #include <Oscil.h> #include <tables/cos2048_int8.h> ! Oscil<COS2048_NUM_CELLS, AUDIO_RATE> aCos(COS2048_DATA);

    Oscil<COS2048_NUM_CELLS, AUDIO_RATE> aVibrato(COS2048_DATA); ! const long intensity = 300; ! void setup(){ startMozzi(CONTROL_RATE); aCos.setFreq(220); aVibrato.setFreq(15.f); } ! void loop(){ audioHook(); } ! void updateControl(){ } ! int updateAudio(){ long vibrato = intensity * aVibrato.next(); return aCos.phMod(vibrato); } .P[[Jϓϩάϥϛϯά ɺ͸͡ΊͷҰา ‣ αϯϓϧ4JO Ϗϒϥʔτ
  3. #include <MozziGuts.h> #include <Oscil.h> #include <tables/cos2048_int8.h> ! Oscil<COS2048_NUM_CELLS, AUDIO_RATE> aCos(COS2048_DATA);

    Oscil<COS2048_NUM_CELLS, AUDIO_RATE> aVibrato(COS2048_DATA); ! float intensity = 300.0; ! void setup(){ startMozzi(CONTROL_RATE); aCos.setFreq(220); aVibrato.setFreq(15.f); } ! void loop(){ audioHook(); } ! void updateControl(){ } ! int updateAudio(){ long vibrato = intensity * aVibrato.next(); return aCos.phMod(vibrato); } .P[[Jϓϩάϥϛϯά ɺ͸͡ΊͷҰา ‣ ઌ΄ͲͷϏϒϥʔτͷαϯϓϧ͔Βελʔτ
  4. #include <MozziGuts.h> #include <Oscil.h> #include <tables/cos2048_int8.h> ! Oscil<COS2048_NUM_CELLS, AUDIO_RATE> aCos(COS2048_DATA);

    Oscil<COS2048_NUM_CELLS, AUDIO_RATE> aVibrato(COS2048_DATA); ! float intensity = 300.0; ! int amp = 127; ! void setup(){ startMozzi(CONTROL_RATE); aCos.setFreq(220); aVibrato.setFreq(15.f); } ! void loop(){ audioHook(); } .P[[Jϓϩάϥϛϯά ɺ͸͡ΊͷҰา ‣ ઌ΄ͲͷϏϒϥʔτͷαϯϓϧ͔Βελʔτ ௥Ճ
  5. void updateControl(){ } ! int updateAudio(){ float vibrato = intensity

    * aVibrato.next(); return int(aCos.phMod(vibrato) * amp) >> 8; } .P[[Jϓϩάϥϛϯά ɺ͸͡ΊͷҰา ‣ ઌ΄ͲͷϏϒϥʔτͷαϯϓϧ͔Βελʔτ ௥Ճ
  6. void updateControl(){ int volume = mozziAnalogRead(0); amp = map(volume, 0,

    1024, 0, 255); } ! int updateAudio(){ float vibrato = intensity * aVibrato.next(); return int(aCos.phMod(vibrato) * amp) >> 8; } .P[[Jϓϩάϥϛϯά ɺ͸͡ΊͷҰา ‣ VQEBUF$POUSPM ʹ௥Ճ ௥Ճ
  7. #include <MozziGuts.h> #include <Oscil.h> #include <tables/cos2048_int8.h> ! Oscil<COS2048_NUM_CELLS, AUDIO_RATE> aCos(COS2048_DATA);

    Oscil<COS2048_NUM_CELLS, AUDIO_RATE> aVibrato(COS2048_DATA); ! float intensity = 300.f; float vib = 15.f; int amp = 127; ! void setup(){ startMozzi(CONTROL_RATE); aCos.setFreq(80); aVibrato.setFreq(15.f); } ! void loop(){ audioHook(); } .P[[Jϓϩάϥϛϯά ɺ͸͡ΊͷҰา ‣ ͞ΒʹɺϏϒϥʔτͷप೾਺΋Մมʹ
  8. void updateControl(){ int volume1 = mozziAnalogRead(0); amp = map(volume1, 0,

    1024, 0, 255); int volume2 = mozziAnalogRead(1); intensity = map(volume2, 0, 1024, 0, 20000); int volume3 = mozziAnalogRead(2); vib = map(volume3, 0, 1024, 0, 100); aVibrato.setFreq(vib); } ! int updateAudio(){ float vibrato = intensity * aVibrato.next(); return int(aCos.phMod(vibrato) * amp) >> 8; } .P[[Jϓϩάϥϛϯά ɺ͸͡ΊͷҰา ‣ ͞ΒʹɺϏϒϥʔτͷप೾਺΋Մมʹ