// Scale the next wave sample and place in centre newsample = (newsample / 2) + 64; // generate the BTc bit, // does the BTc wave need to react UP or DOWN to follow it? if(newsample > lastbtc) { newbit = 1; // BTc must move UP dist = (256 - lastbtc); // calc total distance to charge dist = (dist / 4); // BTc4, only charge 1/4 distance lastbtc = (lastbtc + dist); // where it charges up to goto done; } else { newbit = 0; // BTc must move DOWN dist = lastbtc; // calc total distance to charge dist = (dist / 4); // BTc4, only charge 1/4 distance lastbtc = (lastbtc - dist); // where it charges down to goto done; }
// Scale the next wave sample and place in centre newsample = (newsample / 2) + 64; // generate a "1" (high) outcome dist = (256 - lastbtc); // calc total distance to charge dist = (dist / 4); // BTc4, only charge 1/4 distance highbtc = (lastbtc + dist); // where it charges up to // generate a "0" (low) outcome dist = lastbtc; // calc total distance to charge dist = (dist / 4); // BTc4, only charge 1/4 distance lowbtc = (lastbtc - dist); // where it charges down to // calc distance from high outcome (up or down) to new sample if(highbtc > newsample) disthigh = (highbtc - newsample); else disthigh = (newsample - highbtc); // calc distance from low outcome (up or down) to new sample if(lowbtc > newsample) distlow = (lowbtc - newsample); else distlow = (newsample - lowbtc); // see which outcome is closest to new sample and generate the bit if(disthigh > distlow) // low is closest { newbit=0; lastbtc = lowbtc; } else // else high is closest { newbit=1; lastbtc = highbtc; } goto done;
variables; NewSample = the new audio sample, scaled to 1/4-3/4 Vcc range LastVoltage = the cap voltage (audio output) from the last bit NewVoltage = the cap voltage (audio output) after we encode this new bit NewBit = the newly encoded BTc bit encoding; 1. generate a 1bit; distance = (Vcc - LastVoltage) / 8 Voltage1 = LastVoltage + distance 2. generate a 0bit; distance = (LastVoltage - Gnd) / 8 Voltage0 = LastVoltage - distance 3. Find which bit is closest to the desired audio sample; if Voltage1 is closest to NewSample then; NewBit =1, and NewVoltage = Voltage1 if Voltage0 is closest to NewSample then; NewBit =0, and NewVoltage = Voltage0 4. Save the cap voltage and repeat for the next audio sample; LastVoltage = NewVoltage Repeat
variables; NewSample = the new audio sample, scaled to 1/4-3/4 Vcc range LastVoltage = the cap voltage (audio output) from the last bit NewVoltage = the cap voltage (audio output) after we encode this new bit LastBit = the encoded bit from last time NewBit = the newly encoded BTc bit encoding; 1. generate a 1bit; distance = (Vcc - LastVoltage) / 8 Voltage1 = LastVoltage + distance 2. generate a 0bit; distance = (LastVoltage - Gnd) / 8 Voltage0 = LastVoltage - distance 3. voltage won't change if the last bit was different, so; if LastBit was 1; Voltage0 = LastVoltage if LastBit was 0; Voltage1 = LastVoltage 3. Find which bit is closest to the desired audio sample; if Voltage1 is closest to NewSample then; NewBit =1, and NewVoltage = Voltage1 if Voltage0 is closest to NewSample then; NewBit =0, and NewVoltage = Voltage0 4. Save the cap voltage and repeat for the next audio sample; LastVoltage = NewVoltage Repeat
variables; NewSample = the new audio sample, scaled to 1/4-3/4 Vcc range LastVoltage = the cap voltage (audio output) from the last bit NewVoltage = the cap voltage (audio output) after we encode this new bit LastBit = the encoded bit from last time NewBit = the newly encoded BTc bit encoding; 1. if LastBit was 1; (we can move up 1/8 or move down 1/16) generate a 1bit; distance = (Vcc - LastVoltage) / 8 Voltage1 = LastVoltage + distance generate a 0bit; distance = (LastVoltage - Gnd) / 16 Voltage0 = LastVoltage - distance 2. if LastBit was 0; (we can move down 1/8 or move up 1/16) generate a 1bit; distance = (Vcc - LastVoltage) / 16 Voltage1 = LastVoltage + distance generate a 0bit; distance = (LastVoltage - Gnd) / 8 Voltage0 = LastVoltage - distance 3. Find which bit is closest to the desired audio sample; if Voltage1 is closest to NewSample then; NewBit =1, and NewVoltage = Voltage1 if Voltage0 is closest to NewSample then; NewBit =0, and NewVoltage = Voltage0 4. Save the cap voltage and repeat for the next audio sample; LastVoltage = NewVoltage Repeat
variables; NewSample = the new audio sample, scaled to 1/4-3/4 Vcc range LastVoltage = the cap voltage (audio output) from the last bit NewVoltage = the cap voltage (audio output) after we encode this new bit LastBit = the encoded bit from last time NewBit = the newly encoded BTc bit encoding; 1. if LastBit was 1; (we can move up 1/8 or move down 1/32) generate a 1bit; distance = (Vcc - LastVoltage) / 8 Voltage1 = LastVoltage + distance generate a 0bit; distance = (LastVoltage - Gnd) / 32 Voltage0 = LastVoltage - distance 2. if LastBit was 0; (we can move down 1/8 or move up 1/32) generate a 1bit; distance = (Vcc - LastVoltage) / 32 Voltage1 = LastVoltage + distance generate a 0bit; distance = (LastVoltage - Gnd) / 8 Voltage0 = LastVoltage - distance 3. Find which bit is closest to the desired audio sample; if Voltage1 is closest to NewSample then; NewBit =1, and NewVoltage = Voltage1 if Voltage0 is closest to NewSample then; NewBit =0, and NewVoltage = Voltage0 4. Save the cap voltage and repeat for the next audio sample; LastVoltage = NewVoltage Repeat
variables; NewSample = the new audio sample, scaled to 1/4-3/4 Vcc range LastVoltage = the cap voltage (audio output) from the last bit NewVoltage = the cap voltage (audio output) after we encode this new bit LastBit = the encoded bit from last time NewBit = the newly encoded BTc bit encoding; 1. if LastBit was 1; (we can move up 1/8, or move down 1/8 towards destination 1/4Vcc) generate a 1bit; distance = (Vcc - LastVoltage) / 8 Voltage1 = LastVoltage + distance generate a 0bit; distance = (LastVoltage - 1/4Vcc) / 8 Voltage0 = LastVoltage - distance 2. if LastBit was 0; (we can move down 1/8, or move up 1/8 towards destination 3/4Vcc) generate a 1bit; distance = (3/4Vcc - LastVoltage) / 8 Voltage1 = LastVoltage + distance generate a 0bit; distance = (LastVoltage - Gnd) / 8 Voltage0 = LastVoltage - distance 3. Find which bit is closest to the desired audio sample; if Voltage1 is closest to NewSample then; NewBit =1, and NewVoltage = Voltage1 if Voltage0 is closest to NewSample then; NewBit =0, and NewVoltage = Voltage0 4. Save the cap voltage and repeat for the next audio sample; LastVoltage = NewVoltage Repeat