Wave Table Synthesizer(Occilator only). I will make Envelope Generator and MML for play music.

Dependencies:   mbed

Project: Synthesizer. It is using embed to Chip Tune Synthesizer for NXP LPC1768.

At First

Prepare an amplifier with volume wheel. The amplifier wire at pin1 to pin18(D/A converter) from IC Clip or Breedboard.

Play

Check out this project and deploy your mbed. And then push the reset key.

You hear a sound from amplifier.

Modify

First step, you can see main.cpp. This source file plays an occilator with "wait()". Modify frequency at

#define ADD 0x2000000

on the top of source.

Occilator select 7 waveforms.

  • OCC_NONE,
  • OCC_SQUARE,
  • OCC_SINE,
  • OCC_SAW,
  • OCC_WT,
  • OCC_NOISE,
  • OCC_TRIANGLE,

WT means WaveTable Synthesizer.Use "setWave()" function at first.Wavetable will copy in instance.

Change there for waveform.

    gOccilator[0]=Occilator::getInstance(OCC_SAW,INTERRUPT_TIME_US);

INTERRUPT_TIME_US depends sampling rate. Don't change.

Total volume of D/A converter is setting this place.

        gOccilator[0]->setVolume(volume);

By the way, this sample output 0 to 1V(not3.3V) for deforming distortion.

ToDo

  • Envelope generator and LFO(with delay)
  • MML(Music Macro Language)
  • Sample Song(I will make a Japanese Anime music,perhaps)

Project Goal Date

I will make for Comic Market 90(2016.Aug. in Tokyo).And these thing will be written in a Doujinshi.

Revision:
5:3a753cf68fac
Parent:
4:2febde858269
Child:
7:a478d5cc411e
--- a/Occilator.cpp	Sat Jan 30 09:52:44 2016 +0000
+++ b/Occilator.cpp	Tue Feb 02 18:42:49 2016 +0000
@@ -9,6 +9,7 @@
 static Ticker sTicker;
 static long total_value_in_this_span;
 static AnalogOut sAnalogOut(p18);
+static long sMasterVolume=(1/3.3)*0x10000;
 
 /* interrupt handler */
 /*static void tick(uint32_t id);*/
@@ -25,10 +26,16 @@
         case OCC_SINE:
         case OCC_WT:
         case OCC_NOISE:
+        default:
             return NULL;
     }
 }
 
+void Occilator::setMasterVolume(long volume)
+{
+    sMasterVolume=volume;
+}
+
 Occilator::Occilator(long interrupt_us)
 {
     myled1=1;
@@ -81,16 +88,7 @@
 unsigned long Occilator::tick()
 {
     m_Angle+=m_Omega;
-    if (m_Angle & 0x80000000)
-    {
-       myled3 = 1;
-        return (0xffff*m_Volume) >> 16;
-    }
-    else
-    {
-        myled3 = 0;
-        return 0;
-    }    
+    return 0L;
 }
 
 void ::tick()
@@ -105,6 +103,7 @@
         }
     }
     value = value>=0x10000 ? 0xffff : value;
+    value = (sMasterVolume*value)>>16;
     sAnalogOut.write_u16(value);
     myled4=value > 0x80000000;
 }
\ No newline at end of file