Omnimaga

Calculator Community => Casio Calculators => Topic started by: MPoupe on February 23, 2012, 03:55:14 am

Title: Audio player for Casio Prizm
Post by: MPoupe on February 23, 2012, 03:55:14 am
Hello,
I wrote simple program demonstrating audio output on Casio fx cg 20.
Usage:
create wav from your favorite music, PCM,11025 Hz,8 bit,mono and store to the calculator's flash memory as demo.wav.
Copy CGPlayerA.g3a from the attachment here too.
Run it.

As you can see the program is very simple, it uses safe part of the user's stack to load about 450KB of the wav file (so the file doesn't need to be larger). Then it converts the samples and outputs by syscalls.

To be improved:
- increase speed of COM port, 115200 (maximum for syscall) is too slow
- output data asynchronously.

Unfortunately I do not know CPU enough to do it. :-(

Can somebody help ?

Title: Re: Audio player for Casio Prizm
Post by: SimonLothar on February 23, 2012, 09:13:02 am
See fx_calculators_SuperH_based_10.chm
(http://ourl.ca/8207/238670).

Try topic: fx-CG20...Registers, MPU...Accessing the 3pin serial lines directly

Perhaps it helps.
Title: Re: Audio player for Casio Prizm
Post by: DJ Omnimaga on February 23, 2012, 09:45:48 am
I'll try later tonight MPoupe.
Title: Re: Audio player for Casio Prizm
Post by: MPoupe on February 23, 2012, 10:13:05 am
See fx_calculators_SuperH_based_10.chm
(http://ourl.ca/8207/238670).

Try topic: fx-CG20...Registers, MPU...Accessing the 3pin serial lines directly

Perhaps it helps.
Thank you, of course I use your manual :-)
I will try to use 7730.h header (http://pastebin.com/xiyV8CZs)
Title: Re: Audio player for Casio Prizm
Post by: SimonLothar on February 23, 2012, 11:55:35 am
I will try to use 7730.h header (http://pastebin.com/xiyV8CZs)
Be careful with this. 7730 register addresses and bit-assignments are not necessarily compatible with the 7305.
Title: Re: Audio player for Casio Prizm
Post by: Spenceboy98 on February 23, 2012, 04:58:55 pm
Sound like a cool Idea. Might try it later. I did it and it is really quiet to my ears. Good enough for me though.  ;D ;D ;D ;D ;D ;D
Title: Re: Audio player for Casio Prizm
Post by: Yeong on February 23, 2012, 06:37:56 pm
Does it work for cg10?
Title: Re: Audio player for Casio Prizm
Post by: Juju on February 23, 2012, 06:43:08 pm
I'll try. Yay my Prizm could be a wav player. Also is it hard to implement some sort of OGG/MP3 compression?
Title: Re: Audio player for Casio Prizm
Post by: helder7 on February 23, 2012, 07:15:11 pm
only one ear gives sound, like fx9860?

the volume is the same as 9860 or is lower?


I can only test the player at the weekend, because now I have no headset compatible.


Title: Re: Audio player for Casio Prizm
Post by: Juju on February 23, 2012, 07:55:45 pm
It works fine on the fx-CG10. There's a lot of interferences though, and it stops just before the first chorus of Never Gonna Give You Up.
Title: Re: Audio player for Casio Prizm
Post by: DJ Omnimaga on February 23, 2012, 08:24:58 pm
Ok I tried it and I was surprised because the volume is much louder than on the FX-9860G and the TI-84 Plus it seems. :O

There is a bit more noise than on those devices, but it's not too bad on my side it seems. And yeah I had the sound stopping issue too. I loaded in a 1:27 song and it stopped around 30 secs.

Btw I like how much easier it is to listen to calc music with this software than it was with other calc ones. On the 84+ you must open command prompt to convert a wav file to 8xk and stuff like that, and on the 9860G you must use an annoying linking software (FA-124). On the Prizm we don't even need to change the wav extension.

Good job so far. :)
Title: Re: Audio player for Casio Prizm
Post by: Spenceboy98 on February 23, 2012, 09:19:44 pm
Yes I agree. It is a lot easier. NO MORE HASSLE! It does stop after 30 seconds. That part disappointed me. :( Hopefully he can fix that.
Title: Re: Audio player for Casio Prizm
Post by: TIfanx1999 on February 23, 2012, 09:23:46 pm
Hmm... looks cool. I'll have to give it a try when I have a moment. :D
Title: Re: Audio player for Casio Prizm
Post by: DJ Omnimaga on February 23, 2012, 09:25:06 pm
Title: Re: Audio player for Casio Prizm
Post by: Spenceboy98 on February 23, 2012, 09:38:25 pm
Video Response: Do you have a CG 10 or a CG 20? I have a CG10 and it isn't that good.
Title: Re: Audio player for Casio Prizm
Post by: MPoupe on February 24, 2012, 04:13:49 am
Hello, thank you for testing.
The noisy is expected, the D/A frequency is only 115200 bps (fxPlayer uses 1.8 Mbps), I will improve it after I find how.
The 30 seconds duration is also expected and I wrote it in the initial post. The player is synchronous so it loads piece of sound and then it plays (outputs bytes in a loop). I will improve it after I find how to do asynchronous output.
The direct wav support seems to be advantage, but due to limited storage I think I will create more space-saving format.
I think it will use only 4 bit samples so it will have 1/2 of the wav length.
Title: Re: Audio player for Casio Prizm
Post by: DJ Omnimaga on February 24, 2012, 10:41:03 am
Yeah it might be good if there was a different format that was compressed. Would the calculator be fast enough to decompress it while playing, though?
Title: Re: Audio player for Casio Prizm
Post by: MPoupe on February 24, 2012, 12:48:48 pm
Yeah it might be good if there was a different format that was compressed. Would the calculator be fast enough to decompress it while playing, though?
I plan to try mp3, but i am afraid it will be too slow.
Title: Re: Audio player for Casio Prizm
Post by: Eiyeron on February 24, 2012, 01:38:29 pm
NOw make a chiptune tracker! :p
Does it takes many proc power?
Title: Re: Audio player for Casio Prizm
Post by: DJ Omnimaga on February 24, 2012, 02:28:13 pm
It would be nice indeed. Something else that I wonder if it's possible is a MIDI player. Would the calc be fast enough to play multiple instruments at once?
Title: Re: Audio player for Casio Prizm
Post by: DJ Omnimaga on February 25, 2012, 11:02:59 pm
Video Response: Do you have a CG 10 or a CG 20? I have a CG10 and it isn't that good.
CG10. It might be because I recorded while putting the headphone speaker right next to the iPod Touch mic, so this alters the quality a bit and we hear the distortion less. I would have recorded the sound directly on my computer, but I can't find my 3.5mm to 3.5mm cable and I think the quality would be even worse.

Also the distortion is less perceptible on certain headphones.

Sorry btw I didn't notice your comment until now.
Title: Re: Audio player for Casio Prizm
Post by: Spenceboy98 on February 26, 2012, 03:59:46 pm
That's okay.....
Title: Re: Audio player for Casio Prizm
Post by: MPoupe on February 27, 2012, 05:19:02 am
Hello, this is updated version of the wave player.
Changes:
- COM speed increased 4x (to 460800), so it is 1/4 of COM speed used by fxPlayer. This means sound quality is better, but do not expect miracles. I was able to directly access the sio registers (thank you Simon :-) ), but it seems the serial port is less powerful compared to the one in 9860G (one speed register is missing and fifo is only 16 B).
- player remained synchronous, but it is able to play the whole wav - it creates the map of the file in flash and while playing it reads the file from flash directly (see source for details)

I am not sure I will be able to increase the sound quality, I thing I touch the HW limits.
Title: Re: Audio player for Casio Prizm
Post by: Spenceboy98 on February 27, 2012, 05:42:30 pm
It plays better quality, but it isn't very loud. It's awesome. Just keep making upgrades.
Title: Re: Audio player for Casio Prizm
Post by: MPoupe on February 28, 2012, 07:19:42 am
It plays better quality, but it isn't very loud. It's awesome. Just keep making upgrades.
Thank you for testing.
The output could be slightly louder, but I am afraid that quality would decrease.
To make it louder, open cgplayer.c, change line 211:
Code: [Select]
giSubSample = gpBuffer[giBufIndex] >> 4;to
Code: [Select]
giSubSample = gpBuffer[giBufIndex] >> 3;
I hope it will work, I cannot test it just now.
Title: Re: Audio player for Casio Prizm
Post by: helder7 on February 29, 2012, 02:33:01 pm
hi i have a THEORY (only theory) to improve audio player

the ea-200/e-cons2 using the communication system by cable sb-62 (calc-to-calc cable), and is compatible with the Prizm

(http://img833.imageshack.us/img833/9633/img10z.jpg)

it may be possible to find another syscall in this app to improve sound quality or write to RX pin

EDITED:

EA-200 have sound & speaker, calculator group link, etc  :o
(http://img714.imageshack.us/img714/7898/ea200.jpg)

http://edu.casio.com/products/peripheral/ea200/
Title: Re: Audio player for Casio Prizm
Post by: DJ Omnimaga on February 29, 2012, 03:38:44 pm
Wow the new version sounds much better, despite being less loud. It's still louder than most other audio programs though. Also it's nice to hear entire songs play now. :D

Now to find my computer cable...
Title: Re: Audio player for Casio Prizm
Post by: alberthrocks on February 29, 2012, 09:38:09 pm
I tried converting Nyan Cat, but it plays back as high pitched sound. Only when I plug it into my stereo system and turn up the volume 3/4 of the way, I could hear the song. However, that song is also high pitched as well... :P

I'm not too sure if this is converted right. The file size is 2.27 MBs for 3:36 of music.

Is this a bug or a problem on my side? I own a CG-10.

This is my demo.wav: http://dl.dropbox.com/u/1016340/demo.wav
Title: Re: Audio player for Casio Prizm
Post by: DJ Omnimaga on March 01, 2012, 03:47:38 am
It could be because your song was not maxed out, volume-wise. In Audacity you need to increase its volume (amplification) so it's loud enough, else the static produced by the calc will drown the song.

Also I finally found my 3.5mm to 3.5mm cable (and I got my 2.5mm adapter) so I could finally record the calc audio directly to the computer. This is how La Porte du Soleil sounds like on-calc:

http://djomni.57o9.org/prizmlaportedusoleil.mp3

Original song:
Title: Re: Audio player for Casio Prizm
Post by: Eiyeron on March 01, 2012, 04:58:47 am
Hey! I know that muzik! :p
That looks goods anyway, but a bit noisy...
Title: Re: Audio player for Casio Prizm
Post by: Spenceboy98 on March 02, 2012, 04:18:29 pm
How do you record music from your calc to the computer? I have a 3.5 to 3.5 cord and a 2.5 adapter.
Title: Re: Audio player for Casio Prizm
Post by: Eiyeron on March 04, 2012, 04:03:32 pm
1.Put the adaptater inside your calc
2.Put the other jack on the Microphone port (the pink/red)
3.Record with good old windows Recorder, or else
4?
5. Profit
Title: Re: Audio player for Casio Prizm
Post by: alberthrocks on March 04, 2012, 04:11:23 pm
It could be because your song was not maxed out, volume-wise. In Audacity you need to increase its volume (amplification) so it's loud enough, else the static produced by the calc will drown the song.
Nope, I did a full amplification in Audacity, and even allowed clipping.
Title: Re: Audio player for Casio Prizm
Post by: Spenceboy98 on March 11, 2012, 09:31:32 pm
Any progress? Any new features? MPoupe, you need to add a pause function so if you want to get out during the song, you can.
Title: Re: Audio player for Casio Prizm
Post by: MPoupe on March 12, 2012, 12:56:23 pm
Any progress? Any new features? MPoupe, you need to add a pause function so if you want to get out during the song, you can.
No, I had no time to implement anything :-(
BTW: Feel free to modify the player and add any functionality you need (pause included :-) )
Title: Re: Audio player for Casio Prizm
Post by: Spenceboy98 on April 02, 2012, 08:54:18 pm
Here is the CGPlayer with an Overclocked Prizm:



Original Song:

Title: Re: Audio player for Casio Prizm
Post by: ProgrammerNerd on September 18, 2014, 11:02:47 pm
Well sorry for the massive bump but I did a little quick work on this and was able to improve the quality simply by using a new algorithm. It is louder and of higher quality with a small side effect of a quite high pitch noise which can be easily solved with an RC low pass filter and/or faster baud rate. I have some recordings as I have a 2.5mm to 3.5mm cable if anyone wants to hear a comparison. Binary:
https://github.com/ComputerNerd/CGplayer/blob/master/CGplayer.g3a
Source: https://github.com/ComputerNerd/CGplayer/blob/master/src/main.c
And for those who don't want to bother clicking on the link here is the new algorithm it is more simple that what was originally used.
Code: [Select]
unsigned samp=gpBuffer[giBufIndex++]>>3;
if(giBufIndex>=giLength)
return;
unsigned x;
for(x=0;x<4;++x){
if(samp>7){
SCIF2.SCFTDR=255;
samp-=8;
}else{
SCIF2.SCFTDR=ptab[samp];
samp=0;
}
while((SCIF2.SCFDR.WORD >> 8)>=15);
}
Also it uses this table
Code: [Select]
static const unsigned char ptab[]={0,1,3,7,15,31,63,127};
Title: Re: Audio player for Casio Prizm
Post by: DJ Omnimaga on September 18, 2014, 11:33:15 pm
Interesting, I will have to find my cable to hear how it sounds like now. :)
Title: Re: Audio player for Casio Prizm
Post by: ProgrammerNerd on September 19, 2014, 06:51:17 pm
Alright tell me how it sounds.