Wave Table Synthesizer(Occilator only). I will make Envelope Generator and MML for play music.
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.
Occilator.h
- Committer:
- 117Florian
- Date:
- 2016-02-10
- Revision:
- 10:40bed7449a81
- Parent:
- 9:d2a5406650ae
File content as of revision 10:40bed7449a81:
#ifndef _OCCILATOR_H_INCL #define _OCCILATOR_H_INCL #define OCCILATOR_PART_NUM 64 enum Occilator_Type { OCC_NONE, OCC_SQUARE, OCC_SINE, OCC_SAW, OCC_WT, OCC_NOISE, OCC_TRIANGLE, }; class Occilator { public: static Occilator* getInstance(Occilator_Type type,long interrupt_us); /** * Destructor * this destructor anatach the interval timer automatically. */ ~Occilator(); /** * Set angle speed(0x100000000 per 1 round) * frequency is depend on interrupt_us */ void setOmega(long speed); /** * Set volume(0x10000 max volume) * @param volume */ void setVolume(int volume); /** * advance the Angle and caliculate value this span. * it was called by automatically from interval timer. * @return value on this tick(max 0xffff0000) */ virtual unsigned long tick(); long m_Angle; long m_Omega; int m_Volume; /** * Volume for All Channel. * It needs adjust output Voltage(3.3V->1V). * Also this volume don't change. */ static void setMasterVolume(long volume); protected: /** * Constructor(only) * to construct after mbed has started. * this constructor handles interval timer automatically. * @value interrupt_us interrupt span (micro second). it work at first time only. */ Occilator(long interrupt_us); }; #endif