見出し画像

Daisy seed 制作メモ2


Daisy seed 個人の制作メモ。


i2CのOLEDで周波数表示出来ました。

// Title: oscillator
// Description: Control a sine wave freq with a knob
// Hardware: Daisy Seed
// Author: Ben Sergentanis
// Breadboard
// https://raw.githubusercontent.com/electro-smith/DaisyExamples/master/seed/Osc/resources/Osc_bb.png
// Schematic:
// https://raw.githubusercontent.com/electro-smith/DaisyExamples/master/seed/Osc/resources/Osc_schem.png
 #include  "DaisyDuino.h"
 #include  <U8g2lib.h>
 #ifdef  U8X8_HAVE_HW_I2C #include  <Wire.h> #endif 

DaisyHardware hw;

U8G2_SSD1306_128X64_NONAME_F_HW_I2C oled(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);

size_t num_channels;

static Oscillator osc;

float pitchknob;

void MyCallback(float **in, float **out, size_t size) {
 // Convert Pitchknob MIDI Note Number to frequency
 osc.SetFreq(pitchknob);
 for (size_t i = 0; i < size; i++) {
   float sig = osc.Process();

   for (size_t chn = 0; chn < num_channels; chn++) {
     out[chn][i] = sig;
   }
 }
}

void setup() {

 oled.setFont(u8g2_font_inb16_mf);
 oled.setFontDirection(0);
 oled.setFontMode(1);
 oled.begin();
 
 float sample_rate;
 // Initialize for Daisy pod at 48kHz
 hw = DAISY.init(DAISY_SEED, AUDIO_SR_48K);
 num_channels = hw.num_channels;
 sample_rate = DAISY.get_samplerate();

 osc.Init(sample_rate);
 osc.SetFreq(440);
 osc.SetAmp(0.5);
 osc.SetWaveform(osc.WAVE_TRI);

 DAISY.begin(MyCallback);
}

void loop() {
 oled.clearBuffer();
 pitchknob = map((float)analogRead(A0),0.0,1000.0,0.0,3000.0); 

 oled.setCursor(40,40);
 oled.print(pitchknob);


oled.sendBuffer();
 // delay(5);
}
​


64MBの外部メモリについて

>Daisy には、1MB の内部メモリに加えて、64MB の外部メモリが付属しています。

外部メモリを使用する場合は DSY_SDRAM_BSS を変数の前につけると使える。

float  DSY_SDRAM_BSS my_buffer[1024];




よろしければサポートお願いします!