PDA

View Full Version : Roman Black Sound (btc)



Darrel Taylor
- 11th February 2008, 10:05
(Split from a different thread (http://www.picbasic.co.uk/forum/showthread.php?p=50832#post50832))<hr>
Roman, ssssat You?

I have done the btc stuff in PBP.
Worked really well. (depending on bit rate vs RC constant etc)
OK, well it made sounds even if they didn't match, just not quite as good.

Reproduced a few wav files, like spock saying "Fascinating" and a couple others.

But frankly, I got stuck because the conversion program wouldn't open a sound file made after about say 1998 or so. (guesstimate).

Any sound files I find these days didn't work.

To my constant "dismay", I can only report that I lost the entire program in a hard disk crash. I know, sounds like the "Dog ate my homework" but really, that's what happened.

But anyhow, I remember exactly how it was done, and could probably reproduce it, even better since I know how it works. It might even be worth the effort, if the conversion program works better now??????

Best Regards,

THE_RB
- 12th February 2008, 10:01
Hmmmm, "Dog ate my homework"?? (grin)

Hi Darrel, yes it's me. Have we met before?

Cool that you got the BTc working for BASIC! I would love to get a PICBASIC version available to put on my web page or link to on my page.

I don't have a huge amount of time available but I can provide some input or help, and I can also add some "export to BASIC" facility to the 2.0 BTc Encoder if you think it would be popular on the forum for PIC BASIC users.

Please check out the new BTc Encoder, it fixes that bug that wouldn't open some windows-generated .WAV files. It also has some real powerful features like dynamic compression and re-sampling data rates. Things that I had been promising to add for years. :)

Darrel Taylor
- 13th February 2008, 00:37
>> Have we met before?

We have not.
We've talked about your program's a few times around here. I just didn't expect to see you.

Welcome!

I've looked at the new encoder. It's definately works much better now. http://www.picbasic.co.uk/forum/images/icons/icon14.gif
Nice new features too.

Looks like I've got some re-creating to do.

>> and I can also add some "export to BASIC" facility to the 2.0 BTc Encoder if you think ...

I don't think that will be necessary, since PBP can handle ASM files with ease.
However, if you were so inclined, it would be nice to have a second ASM output format.

Something like this would be very helpfull.

Filename macro ; Filename of the original sound (no extensions)
dw 22050 ; Playback Bitrate
dw 832 ; Sound Length in bytes
dw 16 ; bt Constant
dw 1 ; btc model (0=1bit 1=1.5bit)
;----------------------------------------
db 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa ; The sound data
db 0x55, 0xaa, 0x55, 0xb5, 0x52, 0x4a, 0xd2, 0x5a
; etc.
endm

But that's just something to ponder on.

Once I get it re-created, I'll have a better idea. (no doubt)
<hr>
I didn't want to highjack Paul Borgmeier's great thread about your other program, so I've split these posts into to a new thread.

THE_RB
- 13th February 2008, 01:26
Hi again Darrel and thanks for the welcome! :) In fairness I never work with PICBASIC so you probably won't be seeing much of me here. My main reason for searching forums was to get some feedback on the new release of BTc Encoder 2.0 and get some user examples to link to on my web page. I develop commercial hardware and software so my web page has always been sorely neglected, just a few "hobby" style doodads. I am looking at improving it with some of the voluminous work i've done over the last few years.

I'll add your suggestion of outputiing BTc sound data as a DW table to my list of things to do. There are a few people getting back to me with suggestions for the new BTc Encoder so I have a feeling that in a few weeks v2.0 will become super v2.1 ha ha!

Please feel free to contact me by email (or publicly here) if you need anything re the re-creation of your BTc player.

Darrel Taylor
- 14th February 2008, 22:28
Ok, "Dog ate my homework" might have been a "Good thing". :)

Here's a simple "btc Player" that can use any bitrate/btc model.
It has an easy IMPORT function that embeds the sound in the program data.
There are 2 "PLAY" functions. PlaySound, and RepeatSound.

I've changed the format of the ASM files, so this won't be very useful without modifications to the btc encoder. Or an external program can be used to convert the existing ASM/btc files to the new format. I've knocked up a simple program to do that here, but it's really, really ugly. Works for me, but it would be a nightmare for anyone else.

The new ASM format looks like this ...
; Simulated output for DT's suggestion to Roman Black

btc_bitrate = 22050 ; Playback Bitrate
btc_length = 4270 ; Sound Length in bytes
btc_btc = 64 ; bt Constant
btc_model = 1 ; btc model (0=1bit 1=1.5bit)
btc_wordbits = 16 ; 8=retlw, 14=16F's, 16 for 18F
;---------------------------------------------------------
DB 0xB5,0x6A,0xAA,0x52,0xCA,0xA9,0x4B,0x35,0xAD,0xB6, 0xB5,0x9A,0xDB,0x56,0xAA,0xAA
DB 0xB5,0x55,0x52,0x52,0x52,0x12,0x42,0x20,0x84,0x52, 0x99,0x6B,0x5A,0xEE,0xF6,0xF7
DB 0xBB,0xB7,0x75,0xAC,0xA9,0x14,0x52,0x89,0x25,0x28, 0xA9,0x4C,0xA5,0x2A,0x52,0xAA
; etc.

This format allows you to easily Import sound files like this ...
INCLUDE "DT_RBSound.pbp"

@ ImportSound Space, "SpaceNew.asm"
@ ImportSound Bang, "Bang1New.asm"
Each Import line specifies the "Name" to call the sound in the program (Space, Bang), and the associated sound file to load.

Then to play the sound, you simply ...
@ PlaySound Bang
@ RepeatSound Space, 3
<hr>
This is a test program that plays a few sounds from a space game, and a line from kirk and spock.

I've just taken the filtered output from the PIC and fed it into the Line-in of my laptop.
I think the input is loading down the filter, as it sounds much better when I plug it directly into the sound input of my Viewsonic monitor. An op-amp buffer would probably help.

Here is the recorded sound from the example.
http://www.pbpgroup.com/files/picout.mp3


;-- Target = 18F --
@ __CONFIG _CONFIG1H, _OSCS_OFF_1H & _HS_OSC_1H
DEFINE OSC 10

btc_Pin1 VAR PORTC.2
btc_Pin2 VAR PORTC.3
X VAR BYTE
Y VAR BYTE
LATE_LED VAR PORTC.5

INCLUDE "DT_RBSound.pbp"

@ ImportSound Space, "SpaceNew.asm"
@ ImportSound Bang, "Bang1New.asm"
@ ImportSound Hit, "HitNew.asm"
@ ImportSound Shoot, "ShootNew.asm"
@ ImportSound Fascinating, "FascinatingNew.asm"
@ ImportSound Kirk, "BeamUpNew.asm"
@ ImportSound BigGun, "RazorNew.asm"


T1CON = 0

Main:
high LATE_LED
pause 500
low LATE_LED
FOR Y = 1 to 2
FOR X = 1 to 2
@ PlaySound BigGun
Pause 500
NEXT X
@ PlaySound Shoot
Pause 500
NEXT Y
@ PlaySound Hit
Pause 500
@ RepeatSound Hit,10
Pause 1000
@ RepeatSound Shoot, 4
@ RepeatSound BigGun, 2
pause 1000
@ RepeatSound Space, 3
@ PlaySound Bang
Pause 500
@ PlaySound Kirk
Pause 1000
@ PlaySound Fascinating
goto Main


There are still many things that can be done with it, like having a background sound using interrupts. Playing "segments" of a sound file, and probably many more. But for a quick re-creation, it turned out pretty good.

The zip file contains the module, demo program and all the sound files needed to compile it.
<br>

GioppY
- 15th February 2008, 09:47
Would be nice have a 14bit core version.
Regards
Gianni

Darrel Taylor
- 15th February 2008, 09:57
Yup!

Had that in mind with ...
btc_wordbits = 14 ; 8=retlw, 14=16F's, 16 for 18F
Although it would have to be encoded as 2, 7-bit bytes packed in a 14-bit word with "DA".

If Roman has a way to convert it, I got a way to play it.
errr, I'll have a way to play it. (soon) :)
<br>

THE_RB
- 15th February 2008, 14:21
Wow Darrel! You don't mess around hey? You did that so quick and quite neat and professional too. Maybe I should start coding in basic! ;)

Just a couple of things;

1. The code you posted on this page does not include the actual routines that play the sound; PlaySound and RepeatSound. I did find them in the "DT_RBSound.pbp" file that was included in the .ZIP file you posted here. So no drama, I was just confused for a minute how your code worked.

2. I'm having trouble understanding the format of your stored data! Can you please walk me through the following line;



btc_wordbits = 16 ; 8=retlw, 14=16F's, 16 for 18F
;---------------------------------------------------------
DB 0xF8,0x1F,0x80,0xFE,0x01,0xE0,0x3F,0xF8,0x01,0xFF, 0x80,0x1F,0xE0,0xDA,0xA9,0x03
DB 0xFF,0xC0,0x0F,0xFC,0x01,0xFE,0x06,0x55,0xB5,0xA0, 0x3F,0xE0,0x1F,0xC1,0x2D,0xFA


I assume your DB table is BYTES of sound data as converted from my orig .asm "retlw" syntax?

So what is the difference between 8/14/16 as in your comment? What do I need to code up as export options for BTc Encoder??

Maybe the btc_wordbits var might be more beginner friendly as "PIC_core_type" var of 14 or 16 for 14bit core PIC and 16bit core PIC respectively?

Anyway I'm very impressed with what you have put together so quickly and I will link to it on my web page when you are happy that it is all done etc.

THE_RB
- 15th February 2008, 14:26
Yup!

Had that in mind with ...
btc_wordbits = 14 ; 8=retlw, 14=16F's, 16 for 18F
Although it would have to be encoded as 2, 7-bit bytes packed in a 14-bit word with "DA".

If Roman has a way to convert it, I got a way to play it.
errr, I'll have a way to play it. (soon) :)
<br>

Umm, now I'm getting more confused! With .asm data tables in 14bit core pics they still only store 8 bits (as a "retlw" instruction). Unless you have a different system in mind?

Darrel Taylor
- 16th February 2008, 00:18
Wow Darrel! You don't mess around hey? You did that so quick and quite neat and professional too. Maybe I should start coding in basic! ;)
Maybe you should. :)

But having done it before, made it real easy to do again.
The first time took much longer, but this one turned out better. "Good Dog".


So what is the difference between 8/14/16 as in your comment? What do I need to code up as export options for BTc Encoder??

Maybe the btc_wordbits var might be more beginner friendly as "PIC_core_type" var of 14 or 16 for 14bit core PIC and 16bit core PIC respectively?

That's what I started with too, (PIC_type) but then I realized it wasn't really dependant on the Core.

An 18F would be able to play files encoded with any of the 3 formats. Although 16-bit data is the most efficient, using the least amount of flash.
Many 16F's will be able to play either the retlw or 14-bit encodings. It depends on whether that PIC can read it's own flash or not.
For the 16F PIC's that can't access their flash, you're stuck with retlw. But frankly, those PIC's are so small, they wouldn't be able to hold more than a quick "Ding-Dong" sound. Or maybe just the "Ding".

And that's why I went with btc_wordbits. To reflect the number or bits per word, without giving people the impression you had to use 1 specific type depending on the chip you have. Sound encoded with 14-bit can still run just fine on an 18F.


Umm, now I'm getting more confused! With .asm data tables in 14bit core pics they still only store 8 bits (as a "retlw" instruction). Unless you have a different system in mind?
I DO!

There are a couple ways to do the 14-bit encoding, using the MPASM opcodes DA or DW. You end up with the same thing either way.

With DA, it takes two 7-bit numbers and packs them into a single 14-bit Word.
If you were to convert 8-bit data to a 14-bit packed stream, it might look something like this ...
btc_wordbits = 16 ; 8=retlw, 14=16F's, 16 for 18F
;---------------------------------------------------------
DB 0xB5,0x6A,0xAA,0x52,0xCA,0xA9,0x4B,0x35,0xAD,0xB6, 0xB5,0x9A,0xDB,0x56,0xAA,0xAA

0xB5 = 1011010 1 ; Shift Right 1 and save the LSB
= 0x5A

0x6A = 1011010 10 ; Rotate extra bit into next value
; Then shift right again for only 7-bits
= 0x5A

0xAA = 1010101 010 ; Rotate 2 in, and 3 out
= 0x55

0x52 = 0100101 0010 ; 3 In, 4 out
= 0x25

This continues on for another 3 bytes.
Every 7-bytes, there's an extra byte, and no extra bit's.
Then you can put the data in a "DA" statement which packs each 2 bytes in a 14-bit word.

btc_wordbits = 14 ; 8=retlw, 14=16F's, 16 for 18F
;---------------------------------------------------------
DA 0x5A,0x5A,0x55,0x25,...

Of course, since you may have the data in a binary stream in your encoder.
You may just need to take 7-bits at a time, and put them in Bytes.

Using DW is very similar, except you break the data into 14-bit words, instead of 7-bit bytes.
Then you can make the data like this.

btc_wordbits = 14 ; 8=retlw, 14=16F's, 16 for 18F
;---------------------------------------------------------
DW 0x2D5A,0x2AA5, ...


And just a quick note on the retlw format.
All those ORG statements make it impossible to use with PBP because those addresses are occupied by PBP's System Library.
The problems of Locating the data, and Page switching if it crosses a boundary can be handled in the software. But the data should be allowed to go anywhere in the PIC. Not at predetermined addresses. So there's no real need to have the ORG's in there.


Anyway I'm very impressed with what you have put together so quickly and I will link to it on my web page when you are happy that it is all done etc.
And I am impressed with the quality of the sound with such small encoded btc files.
So we're even. :)

While this program is currently written for PBP. The same thing can be made to work in straight ASM too.
So not only will you get a PicBasic version, you'll get a new ASM one too.

Once we have it all working, I'll optimize it down to ASM, which should speed it up a bit. Right now it putters out on 44100bps unless using 20mhz crystal or higher. It should be able to play 44100 with a 4mhz crystal, but that'll come later.

Thanks alot for all your effort. And please take your time.
I'm sure we both have other things to attend too as well.
But if you have questions, don't wait.

Best regards,

Bruce
- 16th February 2008, 04:40
Roman. Very nice utility you have there. Nice work. I was totally surprised when I ran Darrels' example, and it sounded as good as it did. Way impressive.

Darrel. I'm always impressed with your macros. I'm really surprised I don't see more of the #V option used in Microchip macro examples. That ImportSound macro was really impressive work. I would have to call that one "art". You just don't see this. Even in some of the more advanced code examples from engineers that work for Mchip.

You really should write more articles on using built-in PBP macros & using various MPASM macro options. Honestly.

I also like your use of the EXT option with PBP. Timer1 VAR WORD EXT is really cool, as long as some newbie doesn't setup an 18F part for a 16-bit R/W timer..;o}

This project has some very serious potential. Background sounds with ints is a major hint. I would bet this could even beat something like the SpeakJet with a little more work.

I'm looking forward to seeing where this one lands for sure..;o}

THE_RB
- 16th February 2008, 13:56
OK thanks for writing that all up Darrel, it all seems to make sense now. :)

You are right in that it is probably the best solution for everybody for me just to export the sound data already in the formats you need for PBP. So I need to add 3 export options to the BTc Encoder export menu!

Lets see if I got this right;
(with all formats bits are played from left to right)

1. retlw format for 14 bit core PICs;
Ok so if I understand you right you want NO ORG statements at all and the sound data formatted vertically like this;
retlw 0x55 ;
retlw 0x46 ; (etc)

2. DA (or DW which do you prefer?) for 14 bit core PICs;
DA 0x1551, (x8 words per line?)
(where there are 14 bits from the BTc data stream, and left padded with 2 zeros)

2. DW (or DB ?) for 16 bit core PICs;
DW 0x5546, (how many per line?)
(or) DB 0x55, 0x46 (etc)
(obviously 16 bits of sound data or 8 bits of sound data)

I have time over the next 2 weeks to add these 3 export options, if you could just answer the above queries that would be great!

Re the "small" 14 bit core PICs, the 16F876/877 are still very popular with the hobby crowd and with 15625 Hz playback they will fit about 4 seconds of sound in internal rom which is quite a lot, plenty for talking remote controls and simple user feedback systems etc.

To Bruce- I agree totally that a cut down int driven version is a good thing. Part of the reason I added freq resampling to the BTc Encode was so people can play sound at any bitrate their int uses, ie like 4mHz/inst and 256 inst/int gives 15,625 Hz which has been a popular playback freq. All the int needs to do it output one bit every int, as you can image that suits low power PIC projects. I have some .asm code of my own for cut down apps which is crude but I will put it up on my page soon anyway. Believe me it has nothing like the elegance of Darrel's code above!

Also re sound quality, I think maximising volume of Darrel's samples would have given even better sound quality. As the PCM noise is of a fixed amplitude, pumping the signal volume to the max BEFORE encoding yields a major improvement in sound quality.

Darrel Taylor
- 16th February 2008, 22:39
Darrel. I'm always impressed with your macros. I'm really surprised I don't see more of the #V option used in Microchip macro examples. That ImportSound macro was really impressive work. I would have to call that one "art". You just don't see this. Even in some of the more advanced code examples from engineers that work for Mchip.
WOW, thanks Bruce!
I thought it was cool too, but "Art"?

And if I wrote it all down, those guy's at mchip would make more money by impressing their bosses. Microchip would make more money by selling more chips. And at best, I get $100 a page, and loose all my best tricks. :)


I also like your use of the EXT option with PBP. Timer1 VAR WORD EXT is really cool, as long as some newbie doesn't setup an 18F part for a 16-bit R/W timer..;o}
Yeah, I should probably stop showing that, just for the Newb reason.
Or maybe just add an FDA warning on the label....

<dl><dt>Warning:</dt><dd>Using this program could result is severe gastrointestinal diseases, most commonly in the form of acid reflux, or unspecified severe heartburn. Other symptoms may include but are not limited to, nausea, vomiting, diarrhea, hair loss, or pulmonary problems such as heart attack or stroke.

Symptoms may subside after setting the timer's RD16 bit to 0. :D</dd></dl>

Darrel Taylor
- 16th February 2008, 22:41
Roman,

Looks like you got it all straight.
As for the preferences, I'd like to put a hold on that for a moment.

Just talking about how to do it, has brought up new ideas that may help make things more compatible between the varieties of PIC's.

I'm playing with it here to see if I can make it work or not.
It's really just the same stuff as above, but with better options.
I'll let you know soon.

Regards,

Archangel
- 16th February 2008, 23:17
Hi Roman,
Just a quick note to say Thank You, as it was your linistepper that got me interested in PICs.
JS

Darrel Taylor
- 17th February 2008, 03:55
Roman,

OK, wasn't sure before. But I am now.

I have an import function that works on ANY PIC. (ASM or PBP)
With a single exported btc file format.

Conversions to 14-bit data or retlw are handled by MPASM (if necessary). :cool:

Just need to make the player work with each type, and I'm good to go.

Please HOLD!
<br>

GioppY
- 17th February 2008, 15:46
IMHO the attached sample works at 22050Hz 1 bit
it uses a 12F675 @20MHz and an external I2C eeprom (24C256)
The i2cread statement needs about 170uS to respond(@ 20MHz); i suppose that 44100Hz sampling rate can be obtained.
Have fun.
Regards
Gianni

GioppY
- 17th February 2008, 19:17
Obviously the eeprom must be pre loaded with the binary file (filename.btc)
A simple file transfer through com port could be interesting.
Regards
Gianni

omer
- 17th February 2008, 23:05
RB_Sound schematic

Darrel Taylor
- 17th February 2008, 23:26
You can go to Romans website for a schematic, and description of how it works.

http://www.romanblack.com/picsound.htm
<br>

leetzeyin
- 11th September 2008, 11:43
Hi,

this is the first time i'm using the sound encoder, but i'm writing the software in mikroC language. Does anyone here knows mikroC language (or C language)?




Where should i call the .C file function(below) from my main program?

void sound_data1() org (1 * 256)
{
asm retlw 0x12 ;
asm retlw 0x5E ; .....}

i tried to write like this:
PORTB.F4=sound_data1();
but i don't think is correct because there are 2 output ports from the PIC shown in the diagram.


// Digital ----------2R-----,
// |
// Digital ----------2R-----*----- Analogue
// | out
// |
// |
// C = 0.22 uF
// |
// |
// |
// Gnd




Thanks !!!

Acetronics2
- 11th September 2008, 18:04
Hi, Leetzeyin

Why not ask it directly here :

http://www.mikroe.com/forum/viewforum.php?f=13&sid=f9876c747d2cb52faf4d9546d98f2797

I think they already dealt with this encoding system ...

Alain

skimask
- 11th September 2008, 19:17
Hi, Leetzeyin
Why not ask it directly here :
Alain
Didn't you get the memo?
Apparently, PicBasicPro = mikroC = Proton Basic = mikroBasic = Assembly = Everything else... :D

sirvo
- 10th December 2008, 04:19
How do I download the .btc or .asm or .c file to the eeprom?

Thanks..!

Darrel Taylor
- 11th December 2008, 20:36
I did some experimenting with storing the sound in external EEPROM.
And for sure, you have to be using the MSSP module to read the data.
SHIFTIN or I2CREAD can't keep up with the higher bitrates.

I tried contacting Roman several times by email, and never got an answer, so I kind of forgot about it, and haven't done anymore with it. :o
<br>

sirvo
- 12th December 2008, 01:59
I recorded a 5 sec 8-bit mono 22050Hz sound... then I stored it in the 24C512..

then I put this on the 16F877:



LOOP:
I2CREAD DPIN,CPIN,$A0,B0,[ATUAL, PROX] ' Read 2 locations in a row
B0 = 2
REPEAT
while F_nova = 0 : wend
f_nova = 0
I2CREAD DPIN,CPIN,$A0,B0,[PROX]
b0 = b0 + 1
'UNTIL B0 = 4997
goto loop

disable
PPL: PIR1.0 = 0
TMR1H = LOAD.HIGHBYTE
TMR1L = LOAD.LOWBYTE
BUFFER.6 = ATUAL.7
PORTD.1 = BUFFER.6
PORTD.0 = BUFFER.7
BUFFER = BUFFER << 1
ATUAL = ATUAL << 1
f_ctrl = F_Ctrl + 1
if F_ctrl = 8 then
F_NOVA = 1
f_ctrl = 0
atual = prox
endif
RETURN
ENABLE


Well, what I get is a slow and noise sound of what I had recorded. It is recognizable but isn't that good..

I've tried increasing TMR1 interrupt but it did not make a difference...

So, next steps:

I'll try to user asm interrupts (instant interrupt..DT)
try not to use I2CREAD..(editing: So, i've got to use MSSP..... Well, I suspect that there is no @ HI2CREAD yet, right? :) )

Well, that is all..

danke schön..

Ioannis
- 12th December 2008, 11:08
Darrel, have a look at the attached files. It might help on the audio compression project.

Please rename the files to *.rar and then de-compress them.

Ioannis

Darrel Taylor
- 12th December 2008, 19:49
Hi Ioannis,

What are they?

Roman's btc convertor creates the smallest sound files I've ever seen.
Can't imagine more compression being able to do anything without ruining the sound.

I don't use RAR.
Not brave enough to download free programs from a couple of brothers in Russia. :eek:
<br>

Ioannis
- 12th December 2008, 21:32
Hi Darrel. This is an article from the EDN magazine, February 1999. I thought to save you from the trouble to search the site and download it.

It uses the PIC16C556/12C672 and ADPCM DECODER/ENCODER techniques.

I don't know if they produce smaller files than Romans as I have not tested yet.

OK, i will try to zip it and break it into 2 files. I hope windows ZIP can do that.

Ioannis

Ioannis
- 12th December 2008, 21:44
I made the files *png. Hope that are readable.

Ioannis

Agent36
- 15th December 2008, 11:19
Hi,
How do you convert the .BTC file generated by Romans BTC Sound encoder to a hex file?
Just done a quick search on here and using google, could not find anything that helped.....Found a HEX editor, going to see if I can encode some sound!!
regards

sirvo
- 15th December 2008, 15:51
Probably this is not the correct way but rename the .btc to .bin and try again... It works with WinPic800..

Agent36
- 15th December 2008, 16:06
Hi Sirvo,
Thanks for the reply will try that, I am using the pickit2 programmer to down load the hex file. I can now down load to the eeprom, not sure if the code is right but its a start. I will keep trying.

Did you get your code working ok?
regards Nick

sirvo
- 15th December 2008, 16:22
Hi Nick,

No yet, The sound is still slow.. everytime I listening to it I remember Louis Armstrong singing 'Wonderful World' when played in the K7 Tape... so many years ago...

Please, let me know if you get it working!

Thanks!

Agent36
- 15th December 2008, 16:53
Hi sirvo,
I have not got anything working yet using romans btc sound encoder. I have been trying gioppy's code example with no luck. Not sure if i've got the hex dump right or my calculations. A one seconds worth of hex code wont fit on a 512 eeprom. Its getting to the point where I might offer a payment to someone on the forum to write this bit of code for me or take me through the steps required to get it working. Adding good audio to my project is becoming very hard work.

If I do get something working i'll let you know, I do have some ISD control code if you want it.
regards Nick

Ioannis
- 15th December 2008, 21:06
Nick, why don't you use an ISD device? Sure will have better audio quality.

Ioannis

Agent36
- 15th December 2008, 21:50
Hi Ioannis,
Have you used the ISD chips much? I have managed to write some code for the the isd4003 with SPI control about 18 months ago, but since then that type has been discontinued in the UK. I have got some of the 1700 series chipcorders and have been playing with them in push button mode. The problem I have with them is removing the pop and hiss that that is in the back ground when in play back, if I could remove or attenuate it they would be fine for my application. I found this last week when searching for ideas, it uses the audio out and parallel port for control.

www.fragtag.com.au/ISD_recorder.htm

Which makes them more appealing, like I said if I could remove the noise i'd be using them.
I have the circuit built as per the data sheet, with an lm386 audio amp connected to the speaker output. If you have any ideas they would be great.

regards Nick

Ioannis
- 16th December 2008, 06:57
It was long time ago when I read the datasheets of the ISD products trying to decide which one to use. Finally the project did not mke it to production and I never used these chips, although I have some to experiment. I may do it sometime.

Why not process the file on a sound editor program on the PC, and then use the line out of the PC to record the clean sound to the ISD?

Ioannis

Art
- 18th January 2010, 05:43
I wish I'd noticed this before doing my talking clock.
Or maybe not now that it's done in asm.

BTW EEPROM is good for storing sound.

I think a PicBasic version would be nice though, for projects where everything can
fit in one chip.

Normnet
- 19th January 2010, 01:00
For a version in basic see PIC iPod wav player (http://www.picbasic.org/forum/showthread.php?t=10662)

Norm

ScaleRobotics
- 25th May 2010, 17:44
Here are some number sound files and Darrel Taylor's example program that allow your PIC chip to talk out numbers to you. The RB sound files are pretty scratchy, so if you want a professional sounding product, this is not the way to do it. But it is understandable, and sure beats counting the flashes of an LED. It also uses a lot of storage space for the sound files. But the fact that you can store them on a chip, is pretty cool. Darrel's RB_Sound include file was used, as well as his testRBsound program . Check out post # 5 for his post in this thread.

Here is the suggested filter (Roman Black) that may make it sound a little better.

; R = 25968 ohms
;
; Digital -----------R-----*----- Analogue
; | out
; |
; |
; C = 0.22 uF
; |
; |
; |
; Gnd
;



'************************************************* ********************
'* Name : TestRBsound.pbp from Darrel Taylor *
'* Author : Darrel Taylor, modified by Walter Dunckel for numbers *
'* Date : 5/24/2010 *
'* Version : 0.1 *
'* Notes : This version is limited to 18F's *
'* : with only 1 sound at a time *
'************************************************* ********************
;-- Target = 18F4550 --

asm
__CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
__CONFIG _CONFIG1H, _FOSC_HSPLL_HS_1H
__CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_OFF_2L & _VREGEN_ON_2L
__CONFIG _CONFIG2H, _WDT_ON_2H & _WDTPS_512_2H
__CONFIG _CONFIG3H, _PBADEN_OFF_3H
__CONFIG _CONFIG4L, _LVP_OFF_4L & _XINST_OFF_4L
endasm

DEFINE OSC 48
btc_Pin1 VAR PORTC.1 'sound output pin
btc_Pin2 var portC.3 'dummy pin to keep DT_RBSound.pbp happy
LATE_LED var PORTD.0

DEFINE btc_DATA db
INCLUDE "DT_RBSound.pbp"

@ ImportSound n0, "zero.asm"
@ ImportSound n1, "one.asm"
@ ImportSound n2, "two.asm"
@ ImportSound n3, "three.asm"
@ ImportSound n4, "four.asm"
@ ImportSound n5, "five.asm"
@ ImportSound n6, "six.asm"
@ ImportSound n7, "seven.asm"
@ ImportSound n8, "eight.asm"
@ ImportSound n9, "nine.asm"
@ ImportSound n10, "ten.asm"
@ ImportSound n11, "eleven.asm"
@ ImportSound n12, "twelve.asm"
@ ImportSound n13, "thirteen.asm"
@ ImportSound n14, "fourteen.asm"
@ ImportSound n15, "fifteen.asm"
@ ImportSound n16, "sixteen.asm"
@ ImportSound n17, "seventeen.asm"
@ ImportSound n18, "eighteen.asm"
@ ImportSound n19, "nineteen.asm"
@ ImportSound n20, "twenty.asm"
@ ImportSound n30, "thirty.asm"
@ ImportSound n40, "forty.asm"
@ ImportSound n50, "fifty.asm"
@ ImportSound n60, "sixty.asm"
@ ImportSound n70, "seventy.asm"
@ ImportSound n80, "eighty.asm"
@ ImportSound n90, "ninety.asm"
@ ImportSound n100, "hundred.asm"
@ ImportSound n1000, "thousand.asm"

Main: 'says 140,259
@ PlaySound n1
pause 100
@ PlaySound n100
pause 100
@ PlaySound n40
pause 100
@ PlaySound n1000
pause 100
@ PlaySound n2
pause 100
@ PlaySound n100
pause 100
@ PlaySound n50
pause 100
@ PlaySound n9
pause 3000
goto main
The attached audio sample audio-sound-mp3.zip using a 18f4550 in PIC-USB-STK hardware from Olimex. But you can also get similar sound out of a non amplified piezo speaker using a 5uf capacitor.

ScaleRobotics
- 14th August 2010, 17:39
I had not seen this before. I have not played the files from a PIC yet, but it sounds interesting as well. This C code :( uses a "simplified Adaptive Differential Pulse Code Modulation (ADPCM) algorithm". The files look slightly larger than the Roman Black files, but not by much, comparing to the numbers files sizes. The source code also has an executable file called winspeech.exe which encodes wave files.

4694

Source code: http://ww1.microchip.com/downloads/en/AppNotes/an643.zip

Normnet
- 14th August 2010, 18:14
I had not seen this before. I have not played the files from a PIC yet, but it sounds interesting as well. This C code :( uses a "simplified Adaptive Differential Pulse Code Modulation (ADPCM) algorithm". The files look slightly larger than the Roman Black files, but not by much, comparing to the numbers files sizes.

Source code: http://ww1.microchip.com/downloads/en/AppNotes/an643.zip

See M25P32 PIC Audio. (http://www.hickorytech.net/~normnet/)
Options include 16 bit ADPCM compression to 4 bit in Basic.

Sound quality far better than Roman Black's.
The M25P32 may not be as easily found by now as its transfered ownership.

Norm

ScaleRobotics
- 14th August 2010, 20:09
Is it just me, or is anyone else having problems finding Norms code? Might be a firewall issue, I can click on the attachement, but I can't download it: http://www.protonbasic.co.uk/forum/attachment.php?attachmentid=1451&d=1169530365 When I click on it IE says "Done" but I have a blank screen. And when I look on protons NEW site, i don't see any attachements, which does seem kind of strange. I became a member of their new forum, just in case only members could view attachements. Maybe I have to wait a little while?

In any case, thanks Norm! Very interesting work. I look forward to seing your proton code ... but not sure when I will be allowed to. :( Maybe when I get home to a less restrictive firewall I will have better luck.

Normnet
- 14th August 2010, 20:42
Is it just me, or is anyone else having problems finding Norms code? Might be a firewall issue, I can click on the attachement, but I can't download it: http://www.protonbasic.co.uk/forum/attachment.php?attachmentid=1451&d=1169530365 When I click on it IE says "Done" but I have a blank screen. And when I look on protons NEW site, i don't see any attachements, which does seem kind of strange. I became a member of their new forum, just in case only members could view attachements. Maybe I have to wait a little while?

In any case, thanks Norm! Very interesting work. I look forward to seing your proton code ... but not sure when I will be allowed to. :( Maybe when I get home to a less restrictive firewall I will have better luck.

I'll update my website to include all the files.

The ADPCM basic code was ported from the full C ADPCM code.

Norm

Acetronics2
- 14th August 2010, 20:58
Is it just me, or is anyone else having problems finding Norms code? Might be a firewall issue, .

Hi, Walter

Lol ...

But ... would this help ???

Alain

ScaleRobotics
- 14th August 2010, 21:39
The ADPCM basic code was ported from the full C ADPCM code.

Ooooh! That sounds fantastic. I have some reading to do.

Uh..., yes, that does help a lot, thank you Alain! Thankfully, I am permitted to view them and download them as well! Grrrr to Corporate, Proton, or me. Not sure who to blame, but I will start with myself.

Thanks again Norm and Alain.

Walter

Acetronics2
- 14th August 2010, 22:14
Ooooh! That sounds fantastic. I have some reading to do.

Walter

No luck , the WavPlayer explanations are too big ... 1.6 Mb.

I can post it to you @ your private mailbox ...

Alain

Normnet
- 15th August 2010, 12:56
Walter

Do you have the files?

Norm

ScaleRobotics
- 15th August 2010, 16:31
Yes, thank you. I have all the files that Alain posted here. I do not have the 1.6 meg file he mentions, but I am sure that he will send it. ADPCM has me intrigued, so thanks again for your code.

Walter

Acetronics2
- 15th August 2010, 16:54
Yes, thank you. I have all the files that Alain posted here. I do not have the 1.6 meg file he mentions, but I am sure that he will send it.
Walter

Hi, Walter

Looks a little problem with your Mail :o



This is the mail system at host mwinf5c07.orange.fr.
I'm sorry to have to inform you that your message could not
be delivered to one or more recipients. It's attached below.
For further assistance, please send mail to postmaster.
If you do so, please include this problem report. You can
delete your own text from the attached returned message.
The mail system
<[email protected]>: host gmail.com[74.125.43.27] said: 552
5.7.0 review our attachment guidelines. f21si12297915bkf.11

...
sorry ...

Alain

schu4647
- 8th October 2010, 15:32
It sounded like you don't want to use a 16f because they either don't read their own memory and even if they do the memory is so small that it won't hold long sounds. My question is would a 16f88 for example, be able to pull the audio from a 1meg flash thorugh I2C or is that too slow? If it would work what size oscillator would you need? I hate asking these questions because I am normally for doing my own homework but in this case I don't even know where to start. I have owned PBP for about 10 years and I only use it periodically for simple toggling of IO to test out my hardware. This is probably my most agressive project so far.


Hi, Walter

Looks a little problem with your Mail :o


...
sorry ...

Alain

ScaleRobotics
- 8th October 2010, 16:00
It could probably be made to work in pic16 chips .... but why not pic18? The include files in his post#5 of this thread were written for PIC18 chips.

Darrel says I2C is too slow:


I did some experimenting with storing the sound in external EEPROM.
And for sure, you have to be using the MSSP module to read the data.
SHIFTIN or I2CREAD can't keep up with the higher bitrates.

schu4647
- 8th October 2010, 16:34
Roman Blacks board answers the question for me. He is selling a board that takes in the output from his program. It runs on a 16f micro at 20mhz and with a 1 megabit I2C eeprom can store 24 seconds of sound.

http://www.blackrobotics.com/Brains_for_robots_robotic_controllers.htm


It could probably be made to work in pic16 chips .... but why not pic18? The include files in his post#5 of this thread were written for PIC18 chips.

Darrel says I2C is too slow:

schu4647
- 14th December 2010, 23:25
Here is an update to my project. I brought the roman black board and it does work. I tried many band pass filters and the quality is terrible. The only way to even get decent quality was to have a speaker in an enclosure. That did more to filter out the noise, but it still wasn't great. I settled on a windbond device. I wouldn't waste time or money with this method.

Ioannis
- 15th December 2010, 12:19
Look also at the 4D SOMO Module here: http://www.4dsystems.com.au/prod.php?id=73 .

Ioannis

THE_RB
- 15th December 2010, 12:35
schu4647-
Here is an update to my project. I brought the roman black board and it does work. I tried many band pass filters and the quality is terrible. The only way to even get decent quality was to have a speaker in an enclosure. That did more to filter out the noise, but it still wasn't great. I settled on a windbond device. I wouldn't waste time or money with this method.

Hi, the BTc system was never designed for *high quality* sound! It's strangths are in other ways, mainly that the PIC microcontroller can also be used to do other tasks, all in one self contained module, and that is quite memory efficient.

Which speaker were you using that sounded terrible? For better sound quality I suggest a speaker with a larger diameter, ie 4" or 6". The tiny speakers that are supplied (free of charge!) with the product are not meant for good sound (they are "scratchy") and are only for small self contained applications like little robots, talking remote controls etc.

The BTc module sold is optimised for general purpose control applications and has source code, so you can use that one module to operate servos and play speech clips, or control a small device with some talking feedback. Or be used as a complete talking remote control all with the one PIC in the one module with its own 5v regulator and tiny low-sound quality amp already built in.

If all you want is something to play a sound, or specifically need high quality sound then there are plenty of options including the Winbond chips and $10 MP3 players from the supermarket.

Pimentel
- 30th May 2013, 17:09
Darrel,
I was reading your article on Wiki and decided to test it. I have a proto hardwares done (18F452 + 4MHZ cristal) and I would like very much to use this tool with my circuits. Firstlly I want to understand better some things.
I tested using RB_Sound Folder files (TestRBSound.pbp, DT_RBSound.pbp and the asm files like HitNew.asm, FascinatingNew.asm...)
in the TestRBSound.pbp is assigned:
btc_Pin1 - PORTC.2
btc_Pin2 - PORTC.3
LATE_LED - PORTC.5
well, I wired a led to the PortC.5. It is done
What I need to do with btc_Pin1 and btc_Pin2. How to wire and where?
...others files (Number folder) into the .asm files has a draw:
Digital label + resistor R = 25968 ohms and a 0.22uF capacitor to the ground and Analogue label on junction. Need I to put a speeker here or a buzzer? Or is necessary to use a pre-amplifier? Do you used the BTc.exe (BTC Sound Encoder from Roman Black)? I teste it using a Ding.wav from windows and exported to a ding.asm, but into the files is diferent comparing with your files...Into the one.asm for example you coment "File converted to .BSM format with the freeware btc_convertor by Darrel Taylos...Is it other converter diferent of the BTC Soundd Encoder?

Well...
Then I decided to wire a 26k resistor to portc.2 and a 0.22uF capacitor like the draw, and puted a buzzer on junction only to test. The portC.3 NC.
I compiled with sucess but it don't worked!
The led blink just one time and nothing occur.
I don't know what I need to use, if a buzzer, a speeker, a amplifier, how to wire it with certainly but the led should to blink basead on program!
Then I alterate the program to blink 5 times, and then the led blinked 5 times but after it stoped again...I percever the after @ PlaySound BigGun line, nothing occur (led always low, buzzer low)
If you can help me to use it I would be very happy.
I really apreciate it and woul like to use in my projects