btc Player re-creation

What is Roman Black Sound? Roman Black developed a way to compress sound using a Binary Time Constant (BTc) algorithm. This allows sounds to be saved in sizes that fit on chips like PICs. For more information, and Roman's encoder program, see: http://www.romanblack.com/picsound.htm ""

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 ...

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

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.

And Below example from ScaleRobotics: A number player using Darrel's DT_RBSound include file:

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 = 27K
;
; 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 one hundred forty thousand two hundred fifty nine
    @ 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.

Files to Download:

Audio Sound
Numbers
RB_Sound files

Page last modified on March 06, 2018, at 12:54 PM