Skip to content

Instantly share code, notes, and snippets.

@Zardoz89
Last active December 17, 2015 22:59
Show Gist options
  • Save Zardoz89/5686095 to your computer and use it in GitHub Desktop.
Save Zardoz89/5686095 to your computer and use it in GitHub Desktop.
/*-----------------------------------------------------
Author: <Zardoz>
Date: Fri May 31 15:53:33 2013
Description: BTC 1.6 audio codec player for uMicros
Original codec by Roman Black
Audio Codec description : http://www.romanblack.com/btc_alg.htm
-----------------------------------------------------*/
// NOTE : This output comes from RomamBlack BTc enconder that generates a MikroC
// file. Use this command line to extract byte values and generate a const byte
// array to store samples
// cat input.c | awk '{ print $3 " ," ;}' | grep "0x[0-9A-F]* ," |
// awk 'BEGIN{i=1}{line[i++]=$0}END{j=1; while (j<i) {print line[j] line[j+1] line[j+2] line[j+3] line[j+4] line[j+5] line[j+6] line[j+7]; j+=8}}' > ourput_file.h
// -----------------------------------------------------------------------------
// File Details:
// Size 16000 bits (2000 bytes)
// Sound encoded at 10000 bits/sec
// using BTc11 1bit Algorithm to be decoded on
// the following circuit:
//
//
// R = 5161 ohms
//
// Digital T---------4R-----*----- Analogue
// | out
// Digital L-o/o---1.33R----*
// |
// |
// C = 0.22 uF
// |
// |
// |
// Gnd
//
// 4R = 20K
// 1.33R = 6,8K
//=====================================================
// Bitstream data is in PIC .asm table format,
// in blocks of 256 bytes.
//
// Bits are played from left to right, from ms_bit to
// ls_bit.
//=====================================================
const unsigned short snd_data_len = 2000;
const byte snd_data[] = {
//---------------------------------------------------
// org (1 * 256) // block = 1
//---------------------------------------------------
0x9d ,0x16 ,0xdc ,0xd6 ,0x89 ,0x22 ,0xa5 ,0x6b ,0xae ,0xb5 ,0x29 ,0x22 ,0x55 ,
0x5d ,0x5c ,0xd4 ,0xab ,0xb1 ,0xa1 ,0xc3 ,0x8e ,0x4f ,0x0b ,0x99 ,0xce ,0x1c ,
0x35 ,0x64 ,0x76 ,0x97 ,0x9d ,0x45, //------------------------- 32
0xa5 ,0x95 ,0xa8 ,0x64 ,0xaa ,0xd6 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a ,0x43 ,0x25 ,0xed ,0x23 ,0x8e ,0x28 ,0x66 ,0x3e ,0x67 ,
0x96 ,0xe0 ,0xc9 ,0xc3 ,0xca ,0xb6 ,0xaa ,0x4d ,0x52 ,0xd8 ,0x95 ,0x2b ,0x35 ,
0x9a ,0xd5 ,0x94 ,0xa4 ,0xaa ,0xd5 , //------------------------- 224
0xab ,0x7a ,0x99 ,0x82 ,0x34 ,0xb2 ,0x6f ,0xc9 ,0x36 ,0x0c ,0xb9 ,0x33 ,0xd3,
0x8c ,0xd8 ,0xb3 ,0x32 ,0xb5 ,0x5c ,0xd9 ,0x25 ,0x81 ,0xa9 ,0xb5 ,0xae, 0xaa,
0x52 ,0x90 ,0xb3 ,0x76 ,0xd3 ,0xa4,
//---------------------------------------------------
// org (2 * 256) // block = 2
//---------------------------------------------------
//------------------------- 256
0x5d ,0xc8 ,0x79 ,0x13 ,0x17 ,0x31 ,0xd9 ,0x6c ,0xf0 ,0xb0 ,0xd5 ,0xc9 ,0xc3 ,0xd5 ,0x65 ,0x87 ,0x55 ,0x55 ,0x2d ,0x12 ,0xaa ,0xad ,0xad ,0x5a ,0x54 ,0x92 ,0x53 ,0x5a ,0xef ,0x0d ,0x35 ,0x93 , //------------------------- 288
0x3c ,0x2d ,0x30 ,0xb5 ,0x4a ,0x9e ,0xf1 ,0x73 ,0x0b ,0xaa ,0x62 ,0xd5 ,0x2d ,0xd2 ,0xa9 ,0x72 ,0x71 ,0x23 ,0x25 ,0xad ,0xd5 ,0xd2 ,0xd2 ,0x25 ,0x16 ,0xaa ,0xfb ,0x6a ,0x92 ,0x15 ,0x6e ,0x2c , //------------------------- 320
0xe6 ,0x86 ,0x8c ,0x37 ,0xd1 ,0xf2 ,0x62 ,0xb1 ,0xa9 ,0xd4 ,0xcd ,0xc8 ,0xd6 ,0x96 ,0xac ,0x1a ,0x8b ,0x2c ,0xe5 ,0xd5 ,0x99 ,0x2a ,0x29 ,0xaa ,0xd7 ,0xb6 ,0xaa ,0x24 ,0x25 ,0x6d ,0x67 ,0xa6 , //------------------------- 352
0x51 ,0x4e ,0x0e ,0xd9 ,0x6a ,0x9c ,0x33 ,0x69 ,0x55 ,0xad ,0x6c ,0xaa ,0x2a ,0x13 ,0x4b ,0x5b ,0x6a ,0xd2 ,0xa4 ,0x4b ,0x2b ,0x6e ,0xae ,0x13 ,0x9e ,0x63 ,0x41 ,0xe1 ,0x7c ,0x23 ,0xda ,0x5c , //------------------------- 384
0x3e ,0x03 ,0xd4 ,0x37 ,0x8e ,0x5a ,0xb1 ,0x2b ,0xb4 ,0x75 ,0x29 ,0x29 ,0x95 ,0x5d ,0x6a ,0xaa ,0x94 ,0x52 ,0x97 ,0xb5 ,0xe5 ,0x28 ,0xb9 ,0x1c ,0x72 ,0xe1 ,0xc6 ,0x0f ,0x32 ,0xed ,0xad ,0x12 , //------------------------- 416
0x35 ,0x55 ,0x95 ,0xba ,0x5a ,0x99 ,0x59 ,0x55 ,0x25 ,0x18 ,0xbb ,0x56 ,0xb6 ,0x5a ,0x22 ,0xaa ,0x5d ,0x56 ,0xed ,0x2d ,0x04 ,0xe8 ,0xde ,0x17 ,0x1e ,0x18 ,0x69 ,0xe2 ,0xfc ,0x51 ,0xf1 ,0x1a , //------------------------- 448
0x9b ,0x46 ,0xf4 ,0x5a ,0x93 ,0x65 ,0x2a ,0x94 ,0xd2 ,0xd5 ,0x6d ,0xa9 ,0x2a ,0x8a ,0xb2 ,0xda ,0xeb ,0xaa ,0x45 ,0x45 ,0x46 ,0x79 ,0xbc ,0xb9 ,0x44 ,0x68 ,0x3d ,0x57 ,0x47 ,0x68 ,0xa7 ,0x82 , //------------------------- 480
0xdc ,0xe9 ,0xda ,0x52 ,0xa2 ,0x0d ,0xa9 ,0x6d ,0xad ,0x59 ,0x51 ,0x2c ,0xaa ,0xd7 ,0x32 ,0x6b ,0x1e ,0x38 ,0xf0 ,0xc3 ,0x1d ,0x1f ,0x49 ,0xce ,0x61 ,0x93 ,0x63 ,0x6a ,0x65 ,0x3a ,0xab ,0x58 ,
//---------------------------------------------------
// org (3 * 256) // block = 3
//---------------------------------------------------
//------------------------- 512
0xd5 ,0x54 ,0x46 ,0xa5 ,0xad ,0x53 ,0xcd ,0x54 ,0x9a ,0x8a ,0x9c ,0xb5 ,0xe0 ,0x9f ,0x46 ,0xd0 ,0xf0 ,0xbc ,0x1a ,0x5c ,0x5d ,0x1f ,0x8b ,0x86 ,0xc9 ,0xaa ,0x55 ,0x74 ,0xad ,0x55 ,0x56 ,0x54 , //------------------------- 544
0x52 ,0xa3 ,0x6a ,0xe6 ,0xb6 ,0x52 ,0x94 ,0xb4 ,0xd5 ,0x73 ,0x99 ,0xc0 ,0xf4 ,0x69 ,0x5e ,0x51 ,0xdc ,0x25 ,0x61 ,0xe3 ,0xe3 ,0x63 ,0x53 ,0x4a ,0xc9 ,0xcb ,0x97 ,0x25 ,0x53 ,0x6a ,0x49 ,0x55 , //------------------------- 576
0x6a ,0xa5 ,0xd5 ,0xd1 ,0x51 ,0x55 ,0x5a ,0xad ,0x76 ,0x66 ,0x62 ,0x14 ,0xf4 ,0xb3 ,0xe5 ,0x2e ,0x13 ,0x0f ,0x23 ,0xe7 ,0x0e ,0xb1 ,0x68 ,0x72 ,0xe3 ,0xcb ,0x55 ,0x45 ,0x22 ,0xb5 ,0xab ,0x35 , //------------------------- 608
0x6a ,0x94 ,0xa5 ,0x56 ,0xca ,0xe4 ,0xcb ,0x3b ,0x1e ,0x1c ,0x86 ,0x73 ,0x0c ,0xe3 ,0xcb ,0xa0 ,0xf8 ,0xb2 ,0x6d ,0x0b ,0xab ,0x56 ,0xa6 ,0x36 ,0xa5 ,0x48 ,0xab ,0x57 ,0x52 ,0xd5 ,0xa6 ,0x8a , //------------------------- 640
0xa5 ,0x5a ,0xad ,0x62 ,0xb4 ,0x76 ,0x1d ,0x8e ,0x38 ,0x5d ,0x07 ,0x47 ,0x1e ,0xab ,0x32 ,0xa9 ,0x6b ,0x0d ,0x6a ,0x5c ,0xd4 ,0xad ,0x52 ,0x95 ,0x15 ,0x5b ,0x55 ,0xb4 ,0xd4 ,0xa4 ,0xaa ,0x75 , //------------------------- 672
0x59 ,0xd9 ,0x38 ,0xb4 ,0x91 ,0xf1 ,0x76 ,0x0e ,0x63 ,0x46 ,0xa3 ,0xe7 ,0x8a ,0x3b ,0x16 ,0x2e ,0x96 ,0xaa ,0xb2 ,0xe2 ,0x5a ,0xc9 ,0x2a ,0xd5 ,0x9a ,0x8d ,0x74 ,0xaa ,0x55 ,0x55 ,0x56 ,0xaa , //------------------------- 704
0xec ,0x9c ,0x43 ,0x62 ,0x7a ,0x4e ,0xba ,0x48 ,0x5c ,0x9c ,0x78 ,0xad ,0xb2 ,0xa6 ,0x65 ,0x2b ,0xd2 ,0xb9 ,0x59 ,0x25 ,0x14 ,0xdd ,0x56 ,0xb2 ,0xd2 ,0xa4 ,0xaa ,0x6b ,0x66 ,0xb1 ,0x54 ,0xf4 , //------------------------- 736
0x9b ,0xc3 ,0x89 ,0x63 ,0x31 ,0xe8 ,0xf4 ,0x73 ,0x48 ,0x79 ,0x36 ,0x2d ,0x52 ,0xf3 ,0x4a ,0xa9 ,0xa9 ,0x55 ,0x26 ,0x6b ,0x6b ,0x2a ,0x96 ,0x52 ,0xb4 ,0xb5 ,0x5a ,0xb8 ,0x2e ,0x46 ,0x73 ,0xd4 ,
//---------------------------------------------------
// org (4 * 256) // block = 4
//---------------------------------------------------
//------------------------- 768
0x47 ,0x35 ,0x34 ,0x45 ,0xcf ,0x18 ,0xf4 ,0xb2 ,0xd5 ,0x1a ,0x98 ,0xbd ,0x35 ,0x35 ,0x55 ,0x45 ,0x15 ,0x69 ,0xb9 ,0x73 ,0x56 ,0x29 ,0x2c ,0xaa ,0xe5 ,0xd3 ,0x62 ,0xcc ,0x99 ,0x3c ,0x9c ,0x8f , //------------------------- 800
0x13 ,0x64 ,0x66 ,0xd9 ,0xb1 ,0xaa ,0x9c ,0x39 ,0x35 ,0x3a ,0xb5 ,0x2c ,0xaa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d ,0x8e ,0x73 ,0x64 ,0xe2 ,0x74 ,0xbb ,0x11 ,0xcb ,0x31 ,0xb1 ,0x72 ,0x6e ,0x37 ,0x4c ,0x8c ,0xc6 ,0x55 ,0xca ,0xe7 ,0x4a ,0xa9 , //------------------------- 992
0x53 ,0x26 ,0x55 ,0xb3 ,0x96 ,0xc7 ,0x0c ,0x5a ,0xb3 ,0x2d ,0x3a ,0x9a ,0x8e ,0x2e ,0x8b ,0xe2 ,0xa2 ,0xb4 ,0xd3 ,0x32 ,0x5d ,0xa5 ,0x94 ,0xd9 ,0xa5 ,0x51 ,0xc9 ,0xe9 ,0x55 ,0xaa ,0x6a ,0x91 ,
//---------------------------------------------------
// org (5 * 256) // block = 5
//---------------------------------------------------
//------------------------- 1024
0x32 ,0xad ,0xad ,0xaa ,0xa6 ,0x24 ,0xcc ,0xd4 ,0xe6 ,0xb9 ,0x68 ,0xd0 ,0xc7 ,0x8f ,0x51 ,0x4d ,0x35 ,0x4a ,0xb4 ,0xbb ,0x4d ,0x2a ,0x32 ,0xaa ,0x9a ,0xdb ,0x55 ,0x4b ,0x45 ,0x92 ,0x8d ,0x65 , //------------------------- 1056
0xe2 ,0xba ,0x5a ,0xb2 ,0x43 ,0xc4 ,0xd7 ,0x29 ,0xe6 ,0xd4 ,0x2c ,0x92 ,0xdc ,0xd2 ,0xe6 ,0x55 ,0x65 ,0x1a ,0x9a ,0xd2 ,0xc5 ,0x9a ,0x59 ,0xaa ,0xae ,0x65 ,0x95 ,0x2a ,0x95 ,0x8d ,0xcc ,0x3c , //------------------------- 1088
0x3e ,0x2a ,0xc3 ,0x87 ,0x47 ,0x8b ,0x52 ,0xd6 ,0x75 ,0x61 ,0x52 ,0xe5 ,0x63 ,0x46 ,0xad ,0x54 ,0xda ,0xa2 ,0xd5 ,0x23 ,0x59 ,0x67 ,0x5a ,0x69 ,0x69 ,0x32 ,0x55 ,0x55 ,0xe3 ,0xd1 ,0x92 ,0xcb , //------------------------- 1120
0x52 ,0xc3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------------------------
// org (6 * 256) // block = 6
//---------------------------------------------------
//------------------------- 1280
0x25 ,0x2c ,0xb6 ,0xb6 ,0x4a ,0xca ,0x92 ,0x4e ,0x6b ,0x99 ,0xb2 ,0xb2 ,0xa4 ,0x5a ,0xad ,0xa5 ,0x8a ,0xb9 ,0xc7 ,0x3a ,0x43 ,0x66 ,0x18 ,0xcd ,0x8f ,0x9c ,0x99 ,0x61 ,0xc6 ,0x9a ,0xb5 ,0x6a , //------------------------- 1312
0xaa ,0x55 ,0x49 ,0x65 ,0x54 ,0xba ,0xad ,0x55 ,0x34 ,0xca ,0xaa ,0xc9 ,0xa5 ,0xaa ,0xa6 ,0xcd ,0x55 ,0x31 ,0xc3 ,0x52 ,0x5c ,0xac ,0xb4 ,0xbc ,0x6b ,0xc5 ,0x2a ,0xa6 ,0xa9 ,0xa5 ,0xb5 ,0x59 , //------------------------- 1344
0x54 ,0xa5 ,0x29 ,0x36 ,0xb6 ,0xab ,0x2a ,0xa9 ,0x4a ,0xd5 ,0x96 ,0x33 ,0xaa ,0x68 ,0xb8 ,0xb5 ,0x56 ,0x2e ,0x23 ,0x9a ,0x56 ,0x53 ,0xd6 ,0x8c ,0xcc ,0xd3 ,0x54 ,0x37 ,0xaa ,0x3a ,0x54 ,0xac , //------------------------- 1376
0xa9 ,0x56 ,0x9b ,0x55 ,0x4b ,0x2a ,0xaa ,0x95 ,0x9a ,0xab ,0x3a ,0xb1 ,0xc8 ,0x95 ,0x71 ,0xca ,0xac ,0xea ,0x23 ,0xaa ,0x37 ,0x85 ,0xda ,0x68 ,0x73 ,0x17 ,0x34 ,0xbd ,0x4a ,0x4a ,0x85 ,0x5a , //------------------------- 1408
0xdb ,0x72 ,0xaa ,0x54 ,0x2a ,0xad ,0x76 ,0xaa ,0x4a ,0x9c ,0x72 ,0xf1 ,0x8e ,0x92 ,0x1c ,0x72 ,0xe7 ,0xca ,0x66 ,0x29 ,0x93 ,0xaa ,0xbd ,0x2a ,0xa9 ,0x52 ,0xc6 ,0x4d ,0x55 ,0x3a ,0xb5 ,0x54 , //------------------------- 1440
0xaa ,0xaa ,0xa9 ,0x55 ,0x74 ,0x5a ,0x67 ,0x96 ,0x4c ,0x6c ,0xca ,0x49 ,0xe5 ,0x57 ,0x29 ,0xae ,0x9c ,0x39 ,0x92 ,0xd6 ,0x1a ,0xad ,0x56 ,0x5a ,0x55 ,0x92 ,0x16 ,0xb5 ,0xb6 ,0x95 ,0xaa ,0x2a , //------------------------- 1472
0x2b ,0x5b ,0x4c ,0xae ,0x93 ,0xd0 ,0x6c ,0xad ,0x8b ,0x86 ,0x3e ,0x83 ,0xc7 ,0x1b ,0x65 ,0xa1 ,0xec ,0x1e ,0x4b ,0x2e ,0x72 ,0xca ,0xa2 ,0xd1 ,0x59 ,0x56 ,0xd6 ,0xaa ,0x55 ,0x2a ,0x92 ,0xcd , //------------------------- 1504
0xaa ,0x72 ,0xea ,0xe1 ,0x69 ,0x25 ,0x8b ,0x5a ,0x7c ,0x2f ,0x22 ,0x69 ,0xa5 ,0x6d ,0xd1 ,0xc9 ,0x63 ,0x4b ,0xa6 ,0xd5 ,0x55 ,0x14 ,0x25 ,0x5b ,0x75 ,0xaa ,0xd5 ,0x11 ,0x2a ,0xab ,0x6d ,0x6b ,
//---------------------------------------------------
// org (7 * 256) // block = 7
//---------------------------------------------------
//------------------------- 1536
0x48 ,0xb1 ,0xe9 ,0x95 ,0x8a ,0x3c ,0x33 ,0x2e ,0x37 ,0x4e ,0x85 ,0xc1 ,0xbc ,0x95 ,0xa6 ,0xcd ,0x58 ,0x97 ,0x69 ,0x29 ,0x15 ,0xab ,0x75 ,0xa5 ,0x55 ,0x51 ,0x4a ,0x9a ,0xf6 ,0x5a ,0x61 ,0x6e , //------------------------- 1568
0x94 ,0x33 ,0xc8 ,0xac ,0x87 ,0xe3 ,0x2e ,0x5e ,0x29 ,0x70 ,0x9d ,0x55 ,0xca ,0x9d ,0x2c ,0xa5 ,0xac ,0xa4 ,0x55 ,0x6a ,0xba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48 ,0xaa ,0x26 ,0x6a ,0x4f ,0xd8 ,0x5c ,0xa1 ,0xa4 ,0xe6 ,0x6f ,0x31 ,0xf4 , //------------------------- 1760
0x16 ,0xa5 ,0xad ,0xcd ,0x5a ,0x40 ,0x52 ,0xae ,0xb7 ,0x5a ,0xa9 ,0x20 ,0xaa ,0xd7 ,0xad ,0x96 ,0x99 ,0x26 ,0x9d ,0x47 ,0x31 ,0x96 ,0x32 ,0xcb ,0xcd ,0x53 ,0x83 ,0x4a ,0xcb ,0x3b ,0x38 ,0xee ,
//---------------------------------------------------
// org (8 * 256) // block = 8
//---------------------------------------------------
//------------------------- 1792
0x25 ,0x68 ,0xd4 ,0xc8 ,0xaa ,0xe6 ,0xb5 ,0x65 ,0xa9 ,0x29 ,0x2a ,0x77 ,0x58 ,0xf4 ,0x43 ,0x65 ,0xe5 ,0xca ,0x2b ,0x18 ,0xa6 ,0xb3 ,0xa7 ,0x93 ,0x8a ,0x9d ,0x4a ,0xd4 ,0xd3 ,0x36 ,0x5a ,0x36 , //------------------------- 1824
0x75 ,0x10 ,0xaa ,0x6a ,0xd6 ,0xd6 ,0xaa ,0x28 ,0xa5 ,0xab ,0xd5 ,0xd3 ,0x1c ,0x1a ,0x5c ,0x73 ,0x1b ,0xa0 ,0xaa ,0x2b ,0xd1 ,0xec ,0xe6 ,0x47 ,0x8b ,0x1f ,0x15 ,0xb4 ,0xb4 ,0x6a ,0xb4 ,0xa8 , //------------------------- 1856
0x43 ,0xa5 ,0xd7 ,0x35 ,0x59 ,0x31 ,0x29 ,0x6b ,0x5a ,0xed ,0x4d ,0x18 ,0x8c ,0xb2 ,0x5c ,0xe6 ,0xb3 ,0x23 ,0x2a ,0x5b ,0x96 ,0x67 ,0x52 ,0x39 ,0x46 ,0xba ,0xe9 ,0x96 ,0xa5 ,0x44 ,0x15 ,0x6b , //------------------------- 1888
0xb6 ,0xd5 ,0x54 ,0x84 ,0x8a ,0xbe ,0x79 ,0xa9 ,0xe2 ,0x3c ,0x35 ,0x60 ,0xe5 ,0xc6 ,0xd0 ,0xf8 ,0xd6 ,0x8b ,0x86 ,0x2f ,0x2e ,0x68 ,0xcd ,0x5a ,0xa5 ,0x56 ,0xb2 ,0x28 ,0x69 ,0xb5 ,0x6b ,0x9a , //------------------------- 1920
0xa9 ,0x24 ,0xa6 ,0xb5 ,0xb7 ,0x42 ,0xac ,0x6e ,0x1f ,0x44 ,0x78 ,0x0e ,0x4e ,0xb9 ,0xae ,0x8c ,0xc6 ,0x8e ,0xb3 ,0x8a ,0xb9 ,0xa3 ,0x2b ,0x5a ,0x9a ,0x28 ,0xa5 ,0x5a ,0xbd ,0x6a ,0xa9 ,0x14 , //------------------------- 1952
0xaa ,0xd5 ,0xd5 ,0xb1 ,0x70 ,0x78 ,0x5f ,0x0f ,0x09 ,0xc3 ,0xc4 ,0xad ,0x78 ,0xe6 ,0x64 ,0x7c ,0x5a ,0x9a ,0x3a ,0x5b ,0x83 ,0xaa ,0xb3 ,0x12 ,0x54 ,0xb9 ,0xb5 ,0x55 ,0x75 ,0x12 ,0x55 ,0x35 , //------------------------- 1984
0xad ,0xd3 ,0xd4 ,0x25 ,0x32 ,0x4f ,0x27 ,0x8e ,0x9a ,0x86 ,0xe0 ,0xe6 ,0x99 ,0xcc ,0xf2 ,0x36 ,0x00
};
// -----------------------------------------------------------------------------
/**
* Play a bit "sample" of a sound with BTc1.6 codec
* @param *data Ptr. to sample array
* @param len Array size in bytes
* @param t_pin Pin ThisBit (with 4R)
* @param l_pin Pin LastBit (with 1.33R)
*/
void PlayBTc16(const byte* data, const unsigned short len, byte t_pin, byte l_pin) {
static byte word;
static unsigned short index = 0; // Index of the actual byte of data
static byte nbit_word = 0; // Index for each bit of the actual byte
static boolean l_bit = 0; // Last bit
byte tmp;
// Reads array data and set This and Last pins
nbit_word--;
if (nbit_word > 7) { // At underflow, increse index
nbit_word = 7;
index = (index +1) % len;
word = data[index];
}
tmp = 1 << nbit_word;
tmp = tmp & word; // Extract desired bit
if ( tmp > 0 ) {
digitalWrite(t_pin, HIGH); // Set This bit
if (l_bit == 1) {
pinMode(l_pin, OUTPUT);
digitalWrite(l_pin, HIGH); // Set Last bit
} else {
pinMode(l_pin, INPUT); // Float Last Pin
}
l_bit = 1;
} else {
digitalWrite(t_pin, LOW); // Cleans This Bit
if (l_bit == 0) {
pinMode(l_pin, OUTPUT);
digitalWrite(l_pin, LOW); // Cleans Last bit
} else {
pinMode(l_pin, INPUT); // Float Last Pin
}
l_bit = 0;
}
}
/**
* Play a bit "sample" of a sound with BTc1.6 codec
* @param *data Ptr. to sample array
* @param len Array size in bytes
* @param t_pin Pin ThisBit (with 1.33R)
* @param l_pin Pin LastBit (with 4R)
*/
void PlayBTc17(const byte* data, const unsigned short len, byte t_pin, byte l_pin) {
static byte word;
static unsigned short index = 0; // Index of the actual byte of data
static byte nbit_word = 0; // Index for each bit of the actual byte
static boolean l_bit = 0; // Last bit
byte tmp;
// Reads array data and set This and Last pins
nbit_word--;
if (nbit_word > 7) { // At underflow, increse index
nbit_word = 7;
index = (index +1) % len;
word = data[index];
}
tmp = 1 << nbit_word;
tmp = tmp & word; // Extract desired bit
digitalWrite(t_pin, tmp > 0); // Set This bit
digitalWrite(l_pin, l_bit); // Set Last bit
l_bit = tmp > 0;
}
// Example of use
// Pins definitions
#define THISBIT 17
#define LASTBIT 12
void TMR_Event() {
PlayBTc17(snd_data, snd_data_len, THISBIT, LASTBIT);
}
void setup() {
pinMode(THISBIT, OUTPUT);
pinMode(LASTBIT, OUTPUT);
digitalWrite(THISBIT, LOW);
digitalWrite(LASTBIT, LOW);
OnTimer1(TMR_Event, INT_MICROSEC, 10); // Use Timer1 to play a bit every 10 (10KHz)
}
void loop() {
}
/**
* Play a bit "sample" of a sound with BTc1.6 codec
* @param *data Ptr. to sample array
* @param len Array size in bytes
* @param t_pin Pin ThisBit (with 4R)
* @param l_pin Pin LastBit (with 1.33R)
*/
void PlaySound(const byte* data, const unsigned short len, byte t_pin, byte l_pin) {
static byte word;
static unsigned short index = 0; // Index of the actual byte of data
static byte nbit_word = 0; // Index for each bit of the actual byte
static boolean l_bit = 0; // Last bit
byte tmp;
// Reads array data and set This and Last pins
nbit_word--;
if (nbit_word > 7) { // At underflow, increse index
nbit_word = 7;
index = (index +1) % len;
word = data[index];
}
tmp = 1 << nbit_word;
tmp = tmp & word; // Extract desired bit
if ( tmp > 0 ) {
digitalWrite(t_pin, HIGH); // Set This bit
if (l_bit == 1) {
pinMode(l_pin, OUTPUT);
digitalWrite(l_pin, HIGH); // Set Last bit
} else {
pinMode(l_pin, INPUT); // Float Last Pin
}
l_bit = 1;
} else {
digitalWrite(t_pin, LOW); // Cleans This Bit
if (l_bit == 0) {
pinMode(l_pin, OUTPUT);
digitalWrite(l_pin, LOW); // Cleans Last bit
} else {
pinMode(l_pin, INPUT); // Float Last Pin
}
l_bit = 0;
}
}
// Example of use
// Pins definitions
#define THISBIT 12
#define LASTBIT 11
void TMR_Event() {
PlaySound(snd_data, snd_data_len, THISBIT, LASTBIT);
}
void setup() {
pinMode(THISBIT, OUTPUT);
pinMode(LASTBIT, OUTPUT);
digitalWrite(THISBIT, LOW);
digitalWrite(LASTBIT, LOW);
OnTimer1(TMR_Event, INT_MICROSEC, 11); // Use Timer1 to play a bit every 10 (10KHz)
}
void loop() {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment