New PCM demo

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

User avatar
Memblers
Site Admin
Posts: 3770
Joined: Mon Sep 20, 2004 6:04 am
Location: Indianapolis
Contact:

Post by Memblers » Sun Mar 29, 2009 12:27 am

CKY-2K/Clay Man wrote:
smkd wrote:I used sox to make some 4011 playback roms. i converted some wavs to raw 8bit because i remember i had some trouble getting it to output just 7bit. no problem though, just right shifted it before the write.

http://sox.sourceforge.net/
how'd you do that?
A single LSR instruction will do it. Probably cutting the volume in half on an 8-bit sample would do it too.

smkd
Posts: 101
Joined: Sun Apr 22, 2007 6:07 am

Post by smkd » Sun Mar 29, 2009 12:30 am

for sox i just used something like:
sox -V in.wav -r 8000 -u -b8 -c1 out.raw
which saves to raw mono unsigned 8bit pcm suitable for playback at 8khz. like in audition there is no 7bit option from what i saw. for saving at raw 8bit it's not a big deal since it's just a divide by two to get it to 7bits, whether you have a little program to do that for you or if you just do it on the NES before sending it to 4011.

frantik
Posts: 318
Joined: Tue Mar 03, 2009 3:56 pm

Post by frantik » Sun Mar 29, 2009 1:14 am

Memblers wrote:Probably cutting the volume in half on an 8-bit sample would do it too.
that will get you half way there.. you also have to adjust the offset

User avatar
AWal
Posts: 132
Joined: Wed Oct 06, 2004 8:00 am
Location: Northern New York
Contact:

Post by AWal » Sun Mar 29, 2009 11:15 pm

I took the hard way and wrote some QBasic code to pre-shift a raw audio clip. Kinda sketchy but got the point across and seems to run on the real thing just fine.

Available here:

mediafire.com/awal browse to NGGYU Instrumental.zip

User avatar
koitsu
Posts: 4215
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Post by koitsu » Mon Mar 30, 2009 5:25 am

AWal wrote:... wrote some QBasic code ...
???????????????????????????????

User avatar
Jarhmander
Formerly ~J-@D!~
Posts: 488
Joined: Sun Mar 12, 2006 12:36 am
Location: Rive nord de Montréal

Post by Jarhmander » Mon Mar 30, 2009 4:40 pm

koitsu wrote:
AWal wrote:... wrote some QBasic code ...
???????????????????????????????
PROFIT!!!

User avatar
Banshaku
Posts: 2328
Joined: Tue Jun 24, 2008 8:38 pm
Location: Fukuoka, Japan
Contact:

Post by Banshaku » Mon Mar 30, 2009 6:43 pm

koitsu wrote:
AWal wrote:... wrote some QBasic code ...
???????????????????????????????
I guess that any programming language/tool, as long as you reach your goal, is fine :)

I remember using qbasic when I started programming (gwbasic and commodore basic too). I just keep a copy for nostalgia only.

User avatar
AWal
Posts: 132
Joined: Wed Oct 06, 2004 8:00 am
Location: Northern New York
Contact:

Post by AWal » Tue Mar 31, 2009 2:34 pm

...I knew that would happen...I use it for file op's because my C++ skills are shot in that department...It does get the job done though...If you think that's bad you probably haven't heard of MPGRAPE...

frantik
Posts: 318
Joined: Tue Mar 03, 2009 3:56 pm

Post by frantik » Tue Mar 31, 2009 4:32 pm

here's a php version :D

Code: Select all

<?php

$wav = file_get_contents('wavefile.raw');
$len = strlen($wav);
$newwav = '';

for ($i = 0; $i < $len; $i++)
{	$newwav .= chr( ord(substr($wav,$i,1)) >> 1 );
}

file_put_contents('newwave.raw', $newwav);

?>
or change the code to use .wav files with a standard header

Code: Select all

$newwav = substr($wav, 0, 0x2C);

for ($i = 0x2C; $i < $len; $i++)

User avatar
Banshaku
Posts: 2328
Joined: Tue Jun 24, 2008 8:38 pm
Location: Fukuoka, Japan
Contact:

Post by Banshaku » Tue Mar 31, 2009 7:16 pm

AWal wrote:...I knew that would happen...I use it for file op's because my C++ skills are shot in that department...It does get the job done though...If you think that's bad you probably haven't heard of MPGRAPE...
Nothing wrong with that. You got the job done and that what is important. You can always port it back to C++ once you remember how to do IO again.

For what you mentioned, never heard of it. (Offtopic->) One that I learn at college long time go was called RPG 4 by IBM, for mainframe.. Just imagine writting code similar to assembler but for... making reports :P

User avatar
AWal
Posts: 132
Joined: Wed Oct 06, 2004 8:00 am
Location: Northern New York
Contact:

Post by AWal » Fri Apr 03, 2009 10:46 am

frantik wrote:$wav = file_get_contents('wavefile.raw');
$len = strlen($wav);
$newwav = '';
It all makes sence...and thanks for that...honestly, I avoided having a larger buffer due to some PITA issues with too large a buffer (I seem to remember a 2KByte buffer working fine with PDS), and I couldn't load the entire file into a single variable, hence a 1Byte buffer :?.

johannesmutlu
Posts: 26
Joined: Fri Mar 11, 2011 2:22 pm

whooooooaaaaaaaaaaaaaaaaahhhhhhh

Post by johannesmutlu » Fri Mar 11, 2011 4:47 pm

i tested this demo on my nes powerpak to confirm that it can run on true hardware and not on overpowered emulators,but yes it works.
the looped sample of rick rolf with never let you down is just simply amezing,i dit believe that i was dreaming.
just imagine how infemouse and rare the pcm channel reallly is especially in older gameconsoles,early nes games never maked use of it at alll,i had even readed somewhere that nintendo never had intended to put a pcm channel in their nes rather then fm channels,but that somehow a pcm channel just become possible trrough a discovered trick,not sure if that,s true???
,m mean the fact that the nes can handle samples at 7bits that really blows my miind wich is even better then the 4bit audio you hear in airplanes nasa rockets,millitair airplanes,mobilephones,voice recorder.
it even comes close in quality to the 1 8bit genesis and 1 8bit gba dac,s audio just absolutely amezing!!!!!
now imagine if we can split a hole song in sections and play them one after another trough bankswitching to overcome the limmited memory space.
it would be awesome to listen to craig david music on the nes hey hey!!!

tepples
Posts: 21750
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: whooooooaaaaaaaaaaaaaaaaahhhhhhh

Post by tepples » Fri Mar 11, 2011 4:52 pm

johannesmutlu wrote:just imagine how infemouse and rare the pcm channel reallly is especially in older gameconsoles,early nes games never maked use of it at alll
That's because it requires a lot of ROM space, which was expensive back then.
i had even readed somewhere that nintendo never had intended to put a pcm channel in their nes rather then fm channels
Then explain Kung Fu, Duck Hunt, and a couple other NROM games that used occasional DPCM samples.
the fact that the nes can handle samples at 7bits that really blows my miind wich is even better then the 4bit audio you hear in [...]
A lot of the 4-bit-per-sample applications are actually using ADPCM, which save space by only storing differences from one sample to the next. I've written an ADPCM demo that sounds almost as good as the Rick Roll demo.
now imagine if we can split a hole song in sections and play them one after another trough bankswitching to overcome the limmited memory space.
That would take a lot of CPU time, and doing it while running a game would need some sort of timer to make interrupts.

frantik
Posts: 318
Joined: Tue Mar 03, 2009 3:56 pm

Post by frantik » Mon Mar 14, 2011 4:52 am

as far as the audio quality, i spent a lot of time tweaking the audio, eqing, compressing, etc to make sure it sounded as good as possible even at low bit rates

i was helped by the fact the song is a pop song so it's "loud" all the way through

someone hacked my demo and made a "birthday card" rom for his wife and asked me to put in some different music. the music was just a vocal with lots of silence and it didnt sound nearly as good.. lots of hiss and whatnot

and yeah ive tested it on my power pak and it works fine. coinheaven even put it on a repro cart and it worked. there was a small difference between the power pak and repro carts though.. i guess i didn't initialize the mapper correctly so the song starts at a random place (which is at the beginning of a bank) on the repro cart but always starts at the beginning on the powerpak and all emulators ive tried

User avatar
Kasumi
Posts: 1289
Joined: Wed Apr 02, 2008 2:09 pm

Post by Kasumi » Mon Mar 14, 2011 6:29 pm

I didn't even notice it didn't start at the same place when I put my hack of it on a repropak, but I guess it wasn't in my hands for very long. I realize now I never showed the result after asking for permission to use it. PM me if you're interested.

Post Reply