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.
WT.cpp@7:a478d5cc411e, 2016-02-09 (annotated)
- Committer:
- 117Florian
- Date:
- Tue Feb 09 02:57:27 2016 +0000
- Revision:
- 7:a478d5cc411e
WaveTable???????WT???sin?
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
117Florian | 7:a478d5cc411e | 1 | #include "mbed.h" |
117Florian | 7:a478d5cc411e | 2 | #include "global.h" |
117Florian | 7:a478d5cc411e | 3 | #include "WT.h" |
117Florian | 7:a478d5cc411e | 4 | |
117Florian | 7:a478d5cc411e | 5 | WT::WT(long interrupt_us) : Occilator(interrupt_us) |
117Florian | 7:a478d5cc411e | 6 | { |
117Florian | 7:a478d5cc411e | 7 | //暫定実装 |
117Florian | 7:a478d5cc411e | 8 | unsigned long src[]= |
117Florian | 7:a478d5cc411e | 9 | { |
117Florian | 7:a478d5cc411e | 10 | 0x7FFF, |
117Florian | 7:a478d5cc411e | 11 | 0xB0FA, |
117Florian | 7:a478d5cc411e | 12 | 0xDA80, |
117Florian | 7:a478d5cc411e | 13 | 0xF63F, |
117Florian | 7:a478d5cc411e | 14 | 0xFFFE, |
117Florian | 7:a478d5cc411e | 15 | 0xF63F, |
117Florian | 7:a478d5cc411e | 16 | 0xDA80, |
117Florian | 7:a478d5cc411e | 17 | 0xB0FA, |
117Florian | 7:a478d5cc411e | 18 | 0x7FFF, |
117Florian | 7:a478d5cc411e | 19 | 0x4F03, |
117Florian | 7:a478d5cc411e | 20 | 0x257D, |
117Florian | 7:a478d5cc411e | 21 | 0x9BE, |
117Florian | 7:a478d5cc411e | 22 | 0, |
117Florian | 7:a478d5cc411e | 23 | 0x9BE, |
117Florian | 7:a478d5cc411e | 24 | 0x257D, |
117Florian | 7:a478d5cc411e | 25 | 0x4F03, |
117Florian | 7:a478d5cc411e | 26 | }; |
117Florian | 7:a478d5cc411e | 27 | setWave(src); |
117Florian | 7:a478d5cc411e | 28 | } |
117Florian | 7:a478d5cc411e | 29 | |
117Florian | 7:a478d5cc411e | 30 | void WT::setWave(unsigned long wave[16]) |
117Florian | 7:a478d5cc411e | 31 | { |
117Florian | 7:a478d5cc411e | 32 | for (int i=0;i<16;i++) |
117Florian | 7:a478d5cc411e | 33 | { |
117Florian | 7:a478d5cc411e | 34 | m_Wave[i]=wave[i]; |
117Florian | 7:a478d5cc411e | 35 | } |
117Florian | 7:a478d5cc411e | 36 | } |
117Florian | 7:a478d5cc411e | 37 | |
117Florian | 7:a478d5cc411e | 38 | unsigned long WT::tick() |
117Florian | 7:a478d5cc411e | 39 | { |
117Florian | 7:a478d5cc411e | 40 | Occilator::tick(); |
117Florian | 7:a478d5cc411e | 41 | myled3=1; |
117Florian | 7:a478d5cc411e | 42 | return (m_Wave[(m_Angle >> 28) & 0xf]*m_Volume) >> 16; |
117Florian | 7:a478d5cc411e | 43 | } |