12-polyphonic "chiptune" MIDI synthesizer for LPC1768 (Standalone version)

Dependencies:   ClockControl PowerControl mbed

Committer:
kayekss
Date:
Tue Dec 23 21:50:53 2014 +0000
Revision:
6:cda45a5e723e
Parent:
0:727737138ac5
Supports "Panic on offline" feature when using MIDI-port input

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kayekss 0:727737138ac5 1 #include "defs.h"
kayekss 0:727737138ac5 2 #include "Channels.h"
kayekss 0:727737138ac5 3
kayekss 0:727737138ac5 4 /** Constructor of class Channels */
kayekss 0:727737138ac5 5 Channels::Channels() {
kayekss 0:727737138ac5 6 }
kayekss 0:727737138ac5 7
kayekss 0:727737138ac5 8 /** Destructor of class Channels */
kayekss 0:727737138ac5 9 Channels::~Channels() {
kayekss 0:727737138ac5 10 }
kayekss 0:727737138ac5 11
kayekss 0:727737138ac5 12 /** Initialize all 16 channels */
kayekss 0:727737138ac5 13 void Channels::initializeAll() {
kayekss 0:727737138ac5 14 for (uint8_t i = 0; i < 16; i++) {
kayekss 0:727737138ac5 15 this->volume[i] = 100;
kayekss 0:727737138ac5 16 this->expression[i] = 127;
kayekss 0:727737138ac5 17 this->pitchBend[i] = 0;
kayekss 0:727737138ac5 18 this->wave[i] = Wavetable::waveDefList[4];
kayekss 0:727737138ac5 19 }
kayekss 0:727737138ac5 20 }
kayekss 0:727737138ac5 21
kayekss 0:727737138ac5 22 /** Set volume to channel #i (i: zero origin) */
kayekss 0:727737138ac5 23 void Channels::setVolume(uint8_t i, uint8_t vo) {
kayekss 0:727737138ac5 24 this->volume[i] = vo;
kayekss 0:727737138ac5 25 }
kayekss 0:727737138ac5 26
kayekss 0:727737138ac5 27 /** Set expression to channel #i (i: zero origin) */
kayekss 0:727737138ac5 28 void Channels::setExpression(uint8_t i, uint8_t ex) {
kayekss 0:727737138ac5 29 this->expression[i] = ex;
kayekss 0:727737138ac5 30 }
kayekss 0:727737138ac5 31
kayekss 0:727737138ac5 32 /** Set pitch bend to channel #i (i: zero origin) */
kayekss 0:727737138ac5 33 void Channels::setPitchBend(uint8_t i, int16_t pb) {
kayekss 0:727737138ac5 34 this->pitchBend[i] = pb;
kayekss 0:727737138ac5 35 }
kayekss 0:727737138ac5 36
kayekss 0:727737138ac5 37 /** Set wave parameters of channel #i (i: zero origin) */
kayekss 0:727737138ac5 38 void Channels::setWave(uint8_t i, Wavetable::wave_t w) {
kayekss 0:727737138ac5 39 this->wave[i] = w;
kayekss 0:727737138ac5 40 }
kayekss 0:727737138ac5 41
kayekss 0:727737138ac5 42 /** Get volume of channel #i (i: zero origin) */
kayekss 0:727737138ac5 43 uint8_t Channels::getVolume(uint8_t i) {
kayekss 0:727737138ac5 44 return this->volume[i];
kayekss 0:727737138ac5 45 }
kayekss 0:727737138ac5 46
kayekss 0:727737138ac5 47 /** Get expression of channel #i (i: zero origin) */
kayekss 0:727737138ac5 48 uint8_t Channels::getExpression(uint8_t i) {
kayekss 0:727737138ac5 49 return this->expression[i];
kayekss 0:727737138ac5 50 }
kayekss 0:727737138ac5 51
kayekss 0:727737138ac5 52 /** Get pitch bend of channel #i (i: zero origin) */
kayekss 0:727737138ac5 53 int16_t Channels::getPitchBend(uint8_t i) {
kayekss 0:727737138ac5 54 return this->pitchBend[i];
kayekss 0:727737138ac5 55 }
kayekss 0:727737138ac5 56
kayekss 0:727737138ac5 57 /** Get wave parameters of channel #i (i: zero origin) */
kayekss 0:727737138ac5 58 Wavetable::wave_t Channels::getWave(uint8_t i) {
kayekss 0:727737138ac5 59 return this->wave[i];
kayekss 0:727737138ac5 60 }