Post Reply 
Playing digitized sound files on the HP48G/GX
02-08-2018, 12:27 PM
Post: #1
Playing digitized sound files on the HP48G/GX
Hello,

There are utilitizes which convert 8 bits mono .wav file into a format playable onto the HP 48G(X) calculator.

As far as I know, those utilitizes converts each byte of the sound file into a '1' or a '0', according to the current byte's value. Basically when the value is above 127 it is considered as a '1', otherwise a '0'.

The resulting file is then played by toggling the internal speaker in accordance to the value of each bit.

The advantage is that it takes 8 times less memory than the original .wav file. The sound quality is however extremely low.

So my question is: did someone try to implement a PWM replay routine which would produce a duty cycle in accordance to the original .wav file current byte? The frequency will remain fixed and be that of the .wav file sampling rate but for each byte there will be a specific duty cycle which may produce fairly better sound quality. I don't think it will eat too much processing power as compared to existing playback routines. It will however take 11000 bytes per second for a 11KHz sampling rate.
Find all posts by this user
Quote this message in a reply
02-08-2018, 03:45 PM (This post was last modified: 02-08-2018 03:46 PM by sunhp.)
Post: #2
RE: Playing digitized sound files on the HP48G/GX
That what I did in WariolandHP 20 years ago : https://www.youtube.com/watch?v=fwXA2Y8d...eIQIIX4OKG

Greyscales + sounds = awesome game Big Grin
Visit this user's website Find all posts by this user
Quote this message in a reply
02-09-2018, 09:33 AM
Post: #3
RE: Playing digitized sound files on the HP48G/GX
I do not hear any digitized sound in WariolandHP, only conventional music/FX.
Find all posts by this user
Quote this message in a reply
02-09-2018, 08:56 PM
Post: #4
RE: Playing digitized sound files on the HP48G/GX
(02-09-2018 09:33 AM)Pierre95 Wrote:  I do not hear any digitized sound in WariolandHP, only conventional music/FX.

Yeah I see what you mean, it's just a sum of notes and not analog to digitalised voice.
Visit this user's website Find all posts by this user
Quote this message in a reply
02-09-2018, 09:15 PM
Post: #5
RE: Playing digitized sound files on the HP48G/GX
(02-08-2018 03:45 PM)sunhp Wrote:  That what I did in WariolandHP 20 years ago : https://www.youtube.com/watch?v=fwXA2Y8d...eIQIIX4OKG

Greyscales + sounds = awesome game Big Grin

Some 10 years ago I did it for the 50g (written in C).
It was basically using the PWM timers of the CPU to drive the piezo around 100 kHz, varying the pulse width to recreate arbitrary waveforms at a modest 8 khz.
On top of that I coded a 3 channel mixer and an FM synthesizer, you could feed either an arbitrary sound file or just play up to 3 simultaneous notes using synthetic instruments controlled by several parameters.
The sound system ran in the background, using about 6% of the CPU when running at 6 MHz, so you could leave it playing a tune while you kept working on the calculator.
I had a working demo with a piano (actually a synthetic instrument resembling a piano), where each key was a note and you could press up to 3 simultaneously.
The whole thing was a single source file (unremarkably called 'sound.c'), and somehow I lost it. I wanted to use it as the sound driver for newRPL, but I've been looking for it for a few years now. I don't know why or how but it's not in any of my backups.
Find all posts by this user
Quote this message in a reply
02-09-2018, 09:36 PM
Post: #6
RE: Playing digitized sound files on the HP48G/GX
I think I remember manjo was working on a wave player too at the time (I remember us exchanging some notes about sound), perhaps he published it? Worth looking in hpcalc.org
Find all posts by this user
Quote this message in a reply
02-09-2018, 11:41 PM
Post: #7
RE: Playing digitized sound files on the HP48G/GX
You remember right, I downloaded it at some point and disassembled it. It seemed to be a pretty simple ARM assembly loop actually. I think it was something like: put a byte at some specific memory location, wait some time, repeat with the next byte. I may be off though, because that was before I started to mess with HPGCC3, which I did several years ago...
Here's the link (took a few minutes to find because I couldn't even remember the exact name...): Open Fire Sound Check
Along the way I found these: Piano, SFX Lib, JSBACH. The first two are labeled as 49G+ / 50G-only, the third has different versions for the 49G and 49G+ / 50G. All of this suggests some ARM system interaction. I didn't look into them yet, though.
Find all posts by this user
Quote this message in a reply
02-12-2018, 01:47 PM
Post: #8
RE: Playing digitized sound files on the HP48G/GX
Quote:Yeah I see what you mean, it's just a sum of notes and not analog to digitalised voice.

Anyways WarioLand HP is a great game and one of the most impressive technically speaking. You wrote it alone?

After some questioning I came to the conclusion that it will not be possible to implement all 255
duty cycle values as this would mean a step of 490ns per duty cycle for a 8KHz playback frequency. This cannot be achieved as saturn clock period is around 250ns (4Mhz). The number of duty cycles may therefore be compressed onto 4 bits, requiring 7,8µs per steps which is a more realistic value.
Find all posts by this user
Quote this message in a reply
02-12-2018, 08:21 PM
Post: #9
RE: Playing digitized sound files on the HP48G/GX
(02-12-2018 01:47 PM)Pierre95 Wrote:  
Quote:Yeah I see what you mean, it's just a sum of notes and not analog to digitalised voice.

Anyways WarioLand HP is a great game and one of the most impressive technically speaking. You wrote it alone?

After some questioning I came to the conclusion that it will not be possible to implement all 255
duty cycle values as this would mean a step of 490ns per duty cycle for a 8KHz playback frequency. This cannot be achieved as saturn clock period is around 250ns (4Mhz). The number of duty cycles may therefore be compressed onto 4 bits, requiring 7,8µs per steps which is a more realistic value.

hey thank you, I was a 16 y old kid with plenty of free time at the time, this project was made almost straight from level editor to pixel arts to game engine, not the best gameplay though and also I just cant imagine it has been almost 21 years ago.. time flies.

You should port your great audio project to the HP Prime maybe didn't you ?

Sincerely,
Julien
Visit this user's website Find all posts by this user
Quote this message in a reply
02-12-2018, 11:56 PM
Post: #10
RE: Playing digitized sound files on the HP48G/GX
(02-09-2018 11:41 PM)3298 Wrote:  You remember right, I downloaded it at some point and disassembled it. It seemed to be a pretty simple ARM assembly loop actually. I think it was something like: put a byte at some specific memory location, wait some time, repeat with the next byte. I may be off though, because that was before I started to mess with HPGCC3, which I did several years ago...
Not off at all. The ARM has one of the CPU timers (Timer 2 IIRC) that can be used to automatically flip the bit connected to the speaker. So once you set the clock frequency, all you had to do is to store the duty cycle in a register, the timer would reach that value, automatically flip the bit , and continue counting until the end, flip the bit again and then load the next value, all this automatically. The routine only had to store the next value whenever the timer had used it, and the value (at least in my code) was the duty cycle 0-255 taken from an 8-bit wave file (or synthesized wave). So it was very simple and with minimal CPU use.
Find all posts by this user
Quote this message in a reply
02-15-2018, 03:15 PM
Post: #11
RE: Playing digitized sound files on the HP48G/GX
Quote:I just cant imagine it has been almost 21 years ago

But still does not look outdated...

Quote:You should port your great audio project to the HP Prime maybe didn't you ?

Unfortunately I don't own the Prime.

Everything gets easier when the CPU has an internal timer or one provided on the motherboard. This avoids creating software loop delays requiring a deterministic execution path (which is almost impossible when some interactions are about to occur).

The HP48G/GX has only timer1 and timer2. This last has a rate of 8192Hz which is too slow for modulating the pulse width... The delays shall be implemented through software.
Find all posts by this user
Quote this message in a reply
02-15-2018, 08:59 PM (This post was last modified: 02-15-2018 09:01 PM by sunhp.)
Post: #12
RE: Playing digitized sound files on the HP48G/GX
Thank you!

Maybe this one has a digitalised audio short effect (launch and on losing a life) ?
https://www.youtube.com/watch?v=JAZRyN9s8zg&t=51s

I dont too and I wish there were a Saturn emulator designed for the Prime so one will keep the large catalog of programs.
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)