Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 13:29705e6bf718
- Parent:
- 12:3a1e7fde5040
- Child:
- 14:0fcc949310b7
--- a/main.cpp Thu Dec 07 22:48:14 2017 +0000 +++ b/main.cpp Fri Dec 08 00:04:26 2017 +0000 @@ -101,9 +101,9 @@ testTone = (testTone + carrierIncrements[25]) & 0xffff; - for(int64_t i; i < numKeys; ++i){//for all keys + for(int64_t i = 0ll ; i < numKeys; ++i){//for all keys int64_t keymask = 0x00000001 << i; - keypressed = keyboard & keymask; + keypressed = (keyboard & keymask) != 0; CenvAmp = envelopeAmpsC[i]; MenvAmp = envelopeAmpsM[i]; @@ -149,8 +149,8 @@ modVal = modVal * modVol >> 16; //debug - //modVal = 0; - //CenvAmp = keypressed ? 1 : 0; + modVal = 0; + CenvAmp = keypressed ? 1 : 0; tempPhase = carrierPhases[i] + carrierIncrements[i]; tempPhase = (tempPhase + modVal) & 0xffff; @@ -160,16 +160,16 @@ volumeSum += carVal; } - + if(keyboard != 0ll) + volumeSum += fastSin(testTone); volumeSum = volumeSum / numKeys; volumeSum = (volumeSum * Volume) >> 16; //outMono.write_u16((volumeSum + Volume) > 1); - volumeSum = fastSin(testTone) * 8; + volumeSum *= 8 * numKeys; volumeSum = (volumeSum > 32767) ? 32767 : volumeSum; volumeSum = (volumeSum < -32768) ? -32768 : volumeSum; volumeSum = volumeSum + 32768; - outMono.write_u16(volumeSum); } @@ -202,15 +202,14 @@ carR = 0; keyBank.mode(PullNone); - synthesisClock.attach(synthesize, 0.000025); + synthesisClock.attach(synthesize, 0.000025);//debug while(true){ ratNumer = 0xf & ~ numerator; ratDenom = 0xf & ~ denominator; FMmult = (ratNumer << 16) / ratDenom; - //Volume = (int)inVol.read_u16(); - Volume = 0xffff; + Volume = (int)inVol.read_u16(); modVol = (int)inModAmt.read_u16(); @@ -248,30 +247,21 @@ else modR = 0xffff / ((int)inModR.read_u16()); - //THIS IS CORRECT (1 means the key is connected) - // B8 B7 B6 B5 B4 B3 B2 B1 B0 - // |----||----||----||----||----||----||----||----|| - //0000000000000001111111111111111111111111111111111111111111111111 - // - //THIS IS NOT CORRECT (1 means the key is connected) - // B8 B7 B6 B5 B4 B3 B2 B1 B0 - // |----||----||----||----||----||----||----||----||----| - //0000000000111111111111111111111111111111111111111111111111100000 - //Thus, we need to subtract 5 from our shift + keytemp = 0; //zero the keys before we start ORing on top of everything for(int i = 0; i < 9; ++i) { - bankSelect = (~(1LL << i)) & (unsigned long long)bankSelect.mask(); + bankSelect = (~(1 << i)) & bankSelect.mask(); wait_us(200); int shiftOffset = 6LL * i; - - + keytemp |= ((~(unsigned long long)keyBank) & (unsigned long long)keyBank.mask()) << (unsigned long long)shiftOffset; } keytemp >>= 5; - //keyboard = keytemp; - //debug - keyboard = 0x1000000ll; + keyboard = keytemp; + + + wait_ms(5); } }