Here's a little demo using $4011 to play raw 7bit PCM data while simultaneously doing some graphics stuff and reading from the controller. This is my first demo so let me know what you think
Download demo
Hahaha, excellent. Wins on both counts.
Wow! Amazing quality!! And pretty humorous, too
.
When is the horizontally flipped image used?
it's not used.. i just wanted to put something in the other pattern table for nosy folks lol
glad u guys enjoyed it
D'oh! You got me! haha Pretty nice demo : D
Aw shame, I've just tested it out on WedNESday, but there's no sound emulation at the moment...
No sound? Then you were half-spared
Woah - I didn't know the NES could play anything other than bloop bloop bloop.
cool demo. i thought about 4011 streaming with other tasks crammed in between a little while back, you get a decent chunk of time with 8khz or 16khz between 4011 writes. i thought about using irq to time between 4011 but then i remembered ppu address lines aren't active in nmi so that wouldn't work out too well.
eventually i'd like to write a pcm streamer but i'd also want it doing something in the background otherwise it's pretty unremarkable. i co-authored
something similar for the snes, was pretty fun to make.
Haha, awesome. The audio quality is downright scary.
strat wrote:
I didn't know the NES could play anything other than bloop bloop bloop.
How many words can you make before the sun goes down?
Are. Eye. See. Kay. Rick.
Are. Oh. Ell. Ell. Roll.
Good job! Go again.
I wonder how much the quality would suffer under
ADPCM.
Can Frantik release source code for the NES Demo? And can SMKDan do the same with the SNES Demo? Because the Sound/Music is nice and I'd like them to be released.
tepples wrote:
I wonder how much the quality would suffer under
ADPCM.
haha I actually got the idea from you
musing about the same thing a year ago
It would be interesting to hear using ADPCM compression.. but would you have enough time to decompress it and play the audio in addition to doing everything else? The audio is playing back around 14.5 kHz and there are only 16 clock cycles left between each sample.
one cool thing I discovered is you can get away with using more clock cycles if you only do it once in a while.. like you can do a fair amount of work during vblank and the distortion isn't noticeable until you've wasted a lot of clock cycles.
"Haha, awesome. The audio quality is downright scary."
Honestly, that sounds at least as good as vinyl.
Thanks for the Big Bird vid, Tepples
Never though I'd be rickrolled in a NES demo...seesh...runs very clean, I likes.
Yeah, I had crap results when I experimented with PCM. But until I listened to this, I didn't think they were crappy! I guess I was wrong, because my stuff absolutely pales in comparison to this...
So my question is how did you handle PPU updates and scrolling while also streaming PCM data? Somehow even though I swear the cycle counts were all even, whenever I did a bank switch to get to the next data, there was an inevitable click. Did you just hard code updates in between samples, or did you allow for code to be interrupted somehow?
if you get a click it means you wrote the wrong value to $4011.. timing problems sound like pitch changes or weird warbling. As long as most of the audio is played back at a constant rate, occasionally you can take a
little extra time to do other tasks. the graphics stuff is done during vblank as normal, but really i'm only doing a few things each vblank... I just tried to get the most visual effect out of very few writes to the PPU.
The trickiest part was actually reading the controller.. I do this between each write to $4011. There's some branching that has to be done, but you have to make sure each branch takes the same amount of time. at first I was getting pitch changes when you would hold down the A button but I tuned it (by ear.. it's a lot easier than counting clocks) with blocks of nops.
oh, and i also used the ntsc/pal detection routine on the nesdev wiki and did some timing adjustment based on that as well. it sounds right if you boot in either ntsc or pal mode
Haha. Awesome!
Bonus points för PAL support.
Hey it's great!
I didn't know the NES could play music with this quality, why didn't the games back in the days have this kind of music instead of the classic midi-like?
I know an obvious limitation would be the memory it would take, but appart from that?
Because memory was DAMN EXPENSIVE. Ram was DAMM EXPENSIVE. Rom was DAMN EXPENSIVE. CPUs were DAMN EXPENSIVE.
It's why a modern nes clone costs 30 bucks including a huge multicart of hundreds of pirated games, while the original NES was 200 bucks and games were 50, and that's in pre-inflation dollars.
That and the tune is about 16 seconds and eats up 256KB of ROM.
..that and you can't do much of anything else while doing PCM playback, so it's really only applicable on a title screen (like in Skate Or Die 2).
I don't really think NES music sounds like a SW MIDI synth though.. There's a lot of music on the SNES that does (not that it can't still be really good, like in Megaman X).
mic_ wrote:
..that and you can't do much of anything else while doing PCM playback, so it's really only applicable on a title screen
/me takes this as a challenge... now i have to try and come up with the ultimate mini game
Wow, didn't even check PAL; Impressive. Kudos for that.
I seem to remember the 7-bit RAW audio in Gauntlet II not being half-bad with stuff going on onscreen...although it was probably done at a much lower bitrate.
IIRC on the 2600 Pitfall II had an expansion to multiplex 3 square waves(?) and the chip would give the game code the proper value to write to the TIA. With the limited resources on a 2600 if you wanted BGM you really had to work your code around it (and Gyruss for the 2600 does that very well).
This is the best DPCM I've ever heard in a NES production. Great work dude!
indeed it is PCM.. no delta here buddy
someone on another forum confirmed it works with a powerpak so thats cool
What's the name of that music?
Rick Astley - Never Gonna Give You Up
http://en.wikipedia.org/wiki/Rickroll
Yes it works perfectly on the powerpak. Very impressive!
Fx3 wrote:
What's the name of that music?
OMG you gotta be kidding me...
WedNESday wrote:
Fx3 wrote:
What's the name of that music?
OMG you gotta be kidding me...
I don't live in USA. I'm unable to freely listen'n understand english speaking... Of course such music was much played in Brazil, but the title...
Yes, English is sucks. Here are the lyrics so you can follow along:
"Never Gonna Give You Up" by Rick Astley
Fx3 wrote:
What's the name of that music?
Being
Rickrolled is a big
Internet meme like
All Your Base Are Belong To Us.
Well, my mother language is portuguese. Needless to discuss that, as we're going offtopic. I really hope this isn't a sign of disrespect though.
tepples wrote:
Yes, English is sucks. Here are the lyrics so you can follow along:
"Never Gonna Give You Up" by Rick Astley
Thanks, but I know how to find lyrics.
Fx3 wrote:
Well, my mother language is portuguese. Needless to discuss that, as we're going offtopic. I really hope this isn't a sign of disrespect though.
yeah guys, stay on topic.. this thread is Serious Business!!
blargg wrote:
Fx3 wrote:
What's the name of that music?
Being
Rickrolled is a big
Internet meme like
All Your Base Are Belong To Us.
Thank you blargg!
Fx3 wrote:
Well, my mother language is portuguese. Needless to discuss that, as we're going offtopic. I really hope this isn't a sign of disrespect though.
Of course not.
Attempting to stay on topic...I wanted to note that when I threw my NES into overclock and restarted the program, it detected as PAL, and the playback jumped from about 14750Hz (Approximating) to about 19000Hz...lol.
Oh man Rickroll.nes...I'm gona have fun with this...
Just a heads up I posted a video
here in the case (like I had) where they (target victim) refuse to run the nes file in a emulator due to incompetence/laziness.
How do you convert sound files into 7-bit PCMs?
Make it an 8-bit mono WAV file, and clip off the header (I don't know how big it is, exactly). For each value in the file, load it, shift it right once, and store it into $4011. Then change the time interval between $4011 writes to match the frequency of the WAV file. So if it's 44 KHz, you'll want to write to $4011 44,100 times a second. That's 735 times a frame, which is about once every 40 cycles. I'd recommend not having 44 KHz, because that is horribly space-consuming. But you'll pretty much have to sacrifice one for the other: either space or quality.
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/
there are ways to turn an 8bit wav into a 7 bit wav in a wav editor
I got Adobe Audition.
It can save into many formats but none of them can save as a "7 bit PCM".
Even on "save as raw PCM" it only saves at 8 bits.
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?
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.
for sox i just used something like:
Quote:
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.
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
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
AWal wrote:
... wrote some QBasic code ...
???????????????????????????????
koitsu wrote:
AWal wrote:
... wrote some QBasic code ...
???????????????????????????????
PROFIT!!!
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.
...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...
here's a php version
Code:
<?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:
$newwav = substr($wav, 0, 0x2C);
for ($i = 0x2C; $i < $len; $i++)
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
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
.
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!!!
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.
Quote:
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.
Quote:
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.
Quote:
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.
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
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.
This demo was shown a couple times at MGC.
I guess I could mention too that it was me who hacked it into a birthday "card" for my wife. She loved it BTW
tepples wrote:
I've written an ADPCM demo that sounds almost as good as the Rick Roll demo.
Can you give a link, please?
feos wrote:
tepples wrote:
I've written an ADPCM demo that sounds almost as good as the Rick Roll demo.
Can you give a link, please?
Here's the topic where I last mentioned it. I haven't tried converting music yet though.
tepples wrote:
This demo was shown a couple times at MGC.
cool