CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug Reports on this forum. Send them to support@ccsinfo.com

Playback of 1 bit encoded wav and mp3 files.

 
Post new topic   Reply to topic    CCS Forum Index -> Code Library
View previous topic :: View next topic  
Author Message
davidbue



Joined: 05 Nov 2007
Posts: 28
Location: Denmark

View user's profile Send private message Visit poster's website

Playback of 1 bit encoded wav and mp3 files.
PostPosted: Wed Jun 11, 2008 7:20 am     Reply with quote

Hi everybody.

I just wanted to share with you how I got a PIC18F2220 to play back 1 bit encoded sound files using the BTc Sound Encoder 2.0 Software from www.romanblack.com


http://www.romanblack.com/picsound.htm


I hope you'll find my code useful, and I'd appreciate any feedback that I can use to improve the code.

Code:



#include "C:\soundgen\take1.h"  //Standard, nobrainer header




const char sound_data[] =
{

//Some encoded sound. This is only a few microseconds, but you'll get the idea.

0x12,0x5e,0xaa,0xaa,0xca,0xaa,0xaa,0xb2, 
0xaa,0xa5,0x66,0xcd,0x2a,0xcc,0xcc,0x9a
};

void main()

{


int8 i;
int8 c;
int8 currentbit;

c = sound_data[i];



   setup_oscillator(OSC_8MHZ|OSC_INTRC);
   setup_adc_ports(AN0_TO_AN1|VSS_VDD);
   setup_adc(ADC_CLOCK_INTERNAL|ADC_TAD_MUL_0);


for (i=0; i<17; i++){  //Go through the sound_data array
c = sound_data[i];
//***********************Read bitwise
               for (currentbit = 0; currentbit < 8; currentbit++){


                  if(  bit_test(c,currentbit)  ){  //If the bit is a 1.
                     output_high(pin_b5);
                  }else{                                //If the bit is a 0.
                     output_low(pin_b5);
                  }
                  delay_us(4);

               }
//**********************/Read bitwise
}


// Play a tone after playback of the encoded audio file.
delay_ms(500);
while(1){

output_high(pin_b5);
delay_ms(1);
output_low(pin_b5);
delay_ms(1);

}

}






That's it.

Best regards
David
ratgod



Joined: 27 Jan 2006
Posts: 69
Location: Manchester, England

View user's profile Send private message

PostPosted: Sun Sep 07, 2008 9:15 am     Reply with quote

do you know how to include and play any of the exported files from the BTc Sound encoder from within the PIC?

or rather how could I #include the MikroC file and have that played using your routine? or do you have a converter?
ratgod



Joined: 27 Jan 2006
Posts: 69
Location: Manchester, England

View user's profile Send private message

PostPosted: Sun Sep 07, 2008 9:47 pm     Reply with quote

please ignore my last reply, I have created a small program to convert the MikroC C files that are exported from BTc to C file that you can just #include into your code

http://home.cogeco.ca/~ratgod/BTC2CCS.exe

note: I accept no responsibility for damage cause by misuse of this software, its provided as is.
I've just scanned it with AVG and its clean.

The software converts the layout of the data to the same form as in the example, but it also counts the bytes and makes a define for them.

The software is easy to use, once loaded, you click Select File, then you choose a C file exported from BTc, then click on convert, this will then ask you the destination filename, name this whatever you like, then when the conversion is complete, put the file with you main source code and #include it.

In the example code from davidbue, a line states:
Code:
for (i=0; i<17; i++){  //Go through the sound_data array


I have replaced it with this, so the included file sets the length:
Code:
for (i=0; i<sound_length; i++){  //Go through the sound_data array


I have had a couple of the test files from BTc playing through it.

I'm using a PIC18F2520 with a 20MHz crystal, I'm not sure how to set it to run of the internal 8MHz like yours is set up, any ideas?
acidice333



Joined: 14 Oct 2006
Posts: 33

View user's profile Send private message

PostPosted: Mon Sep 07, 2009 3:05 pm     Reply with quote

Does anything need to change when running at 48mhz?
SherpaDoug



Joined: 07 Sep 2003
Posts: 1633
Location: Cape Cod Mass USA

View user's profile Send private message

How to import BTc sound data into CCS?
PostPosted: Sun Aug 22, 2010 12:10 pm     Reply with quote

Does anyone have a good way to import sound files such as those created by Roman Black's BTc 1 bit Sound Encoder into a CCS program? Roman show an example with 16 sound samples, but I need to use a few hundred samples.

The link in this 2 year old reply is broken.
ratgod wrote:
I have created a small program to convert the MikroC C files that are exported from BTc to C file that you can just #include into your code

http://home.cogeco.ca/~ratgod/BTC2CCS.exe


_________________
The search for better is endless. Instead simply find very good and get the job done.
Jeff King



Joined: 20 Oct 2003
Posts: 43
Location: Hillsdale, Michigan USA

View user's profile Send private message Send e-mail Visit poster's website

Re: How to import BTc sound data into CCS?
PostPosted: Wed Jun 15, 2011 2:04 pm     Reply with quote

SherpaDoug wrote:

The link in this 2 year old reply is broken.
ratgod wrote:
I have created a small program to convert the MikroC C files that are exported from BTc to C file that you can just #include into your code

http://home.cogeco.ca/~ratgod/BTC2CCS.exe



Does anyone have a copy they might be willing to share of the above file? E-mail to king.robert.j@gmail.com if you do and thanks.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> Code Library All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group