Beeb MOD Player

new graphics/music demos - bitshifters, 0xc0de, The Master + others
User avatar
SarahWalker
Posts: 1320
Joined: Fri Jan 14, 2005 3:56 pm
Contact:

Beeb MOD Player

Post by SarahWalker » Mon Jun 28, 2010 12:27 pm

Thought some people might be interested in this - a Beeb .MOD (well converted .MODs really) player. I did have this running briefly at VCF.

It's really meant to run off hard disc / compact flash, but I stuck a few tunes on this disc. You need a Master 128 and the dreaded ADFS. It's not the highest quality (8khz, with 5-bit-ish output based on 4-bit input samples and an 8-bit mixing buffer) but perfectly listenable, and of a similar quality to many Atari ST MOD players. Does sound best on real hardware though - it sounds a bit worse on B-em and a lot worse on Beebem.
Attachments
modplayer.zip
(117.08 KiB) Downloaded 131 times

User avatar
MartinB
Posts: 5353
Joined: Mon Mar 31, 2008 10:04 pm
Location: Obscurity
Contact:

Re: Beeb MOD Player

Post by MartinB » Mon Jun 28, 2010 4:56 pm

I'm trying this on my netbook under B-Em and I seem to get lots of noise in any of the settings so I'll try it on a real Beeb when I get a mo.

Importantly though, what's a MOD? (No parka/scooter jokes please...)

User avatar
iomanoid
Posts: 516
Joined: Sat Aug 08, 2009 10:38 am
Location: Baseworld: Cygni
Contact:

Re: Beeb MOD Player

Post by iomanoid » Mon Jun 28, 2010 5:00 pm

Amiga Soundtracker/Octamed module (song). I can hardly believe this is true, though - eagerly looking forward to having a go myself tonight :D

User avatar
Dave Footitt
Posts: 930
Joined: Thu Jun 22, 2006 10:31 am
Location: Abandoned Uranium Workings
Contact:

Re: Beeb MOD Player

Post by Dave Footitt » Tue Jun 29, 2010 12:00 pm

Nice, why didn't you show me at VCF though? I don't have a Master :(

User avatar
SarahWalker
Posts: 1320
Joined: Fri Jan 14, 2005 3:56 pm
Contact:

Re: Beeb MOD Player

Post by SarahWalker » Tue Jun 29, 2010 1:34 pm

Our host insisted on having BeebSID running, and BeebSID and my CF drive don't like eachother.

User avatar
Samwise
Site Admin
Posts: 1820
Joined: Mon Mar 14, 2005 9:13 pm
Contact:

Re: Beeb MOD Player

Post by Samwise » Tue Jun 29, 2010 5:21 pm

Having been there for its brief unveiling, I can confirm it's more than listenable - it sounded kick-ass ... ;)

Sam.

User avatar
MartinB
Posts: 5353
Joined: Mon Mar 31, 2008 10:04 pm
Location: Obscurity
Contact:

Re: Beeb MOD Player

Post by MartinB » Tue Jun 29, 2010 5:55 pm

Tom wrote:BeebSID and my CF drive don't like eachother.
Surely not - BeebSID has exemplary social skills 8)

Is it because they're both terminated I wonder... :-k

User avatar
SarahWalker
Posts: 1320
Joined: Fri Jan 14, 2005 3:56 pm
Contact:

Re: Beeb MOD Player

Post by SarahWalker » Tue Jun 29, 2010 9:14 pm

Well my CF drive definitely isn't terminated - I completely forgot about termination when making it.

User avatar
simonm
Posts: 316
Joined: Mon May 09, 2016 3:40 pm
Contact:

Re: Beeb MOD Player

Post by simonm » Tue May 10, 2016 6:06 pm

Bit of thread resurrection - Sarah I'm very interested in seeing how you went about implementing your mod player. Your demo disk is awesome.
Would you be open to sharing the source code?
I'm currently noodling with some vgm playback code and audio in general, and the idea of a mod tracker player is something I've thought about for a while. I always thought that mixing in real time would be doable and seems like you've achieved it!

Simon

User avatar
SarahWalker
Posts: 1320
Joined: Fri Jan 14, 2005 3:56 pm
Contact:

Re: Beeb MOD Player

Post by SarahWalker » Tue May 10, 2016 7:25 pm

Sure, I'll see if I can dig out the source.

User avatar
tricky
Posts: 4800
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: Beeb MOD Player

Post by tricky » Tue May 10, 2016 7:37 pm

Very nice, has anyone tried converting it to a .ssd or .dsd and playing it in jsbeeb? It does the best job with the sampled speech in my AstroBlaster.

User avatar
CMcDougall
Posts: 7048
Joined: Wed Feb 02, 2005 3:13 pm
Location: Shadow in a Valley of Scotland
Contact:

Re: Beeb MOD Player

Post by CMcDougall » Tue May 10, 2016 10:01 pm

tricky wrote:anyone tried converting it to a .ssd or .dsd and playing it in jsbeeb?
here is the song "EscColditz" now on a .SSD in Dir S.
It loads 4 samples into swram banks 4,5,6 &7 , then plays.
does jsbeeb have a beeb E00 DFS and 4 banks so can do it.....
Attachments
mod.zip
E00 SSD escColditz
(27.36 KiB) Downloaded 41 times
ImageImageImage

User avatar
SarahWalker
Posts: 1320
Joined: Fri Jan 14, 2005 3:56 pm
Contact:

Re: Beeb MOD Player

Post by SarahWalker » Tue May 10, 2016 10:04 pm

Attached the source for the player. There's a .MOD converter as well, not sure where that is at the moment.

The player code as-is will output to a BeebSID. The code for the internal sound chip, as well as a printer port DAC, are still in the code, just commented out. BeebSID has the benefit of being a lot faster to write to than the internal chip, allowing for the playback frequency to be boosted from 8 to 10 kHz. I think it's also less noisy, despite the drop of resolution to 4 bits. Printer port DAC gives the best quality, but requires you to build a trivial bit of hardware.
Attachments
MODPLAY.txt
(30.1 KiB) Downloaded 51 times

User avatar
tricky
Posts: 4800
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: Beeb MOD Player

Post by tricky » Tue May 10, 2016 10:08 pm

Wow, if that is how good it sounds on a master, I am even more impressed.

User avatar
kieranhj
Posts: 923
Joined: Sat Sep 19, 2015 11:11 pm
Location: Farnham, Surrey, UK
Contact:

Re: Beeb MOD Player

Post by kieranhj » Tue May 10, 2016 10:48 pm

simonm wrote:Bit of thread resurrection - Sarah I'm very interested in seeing how you went about implementing your mod player. Your demo disk is awesome.
Would you be open to sharing the source code?
I'm currently noodling with some vgm playback code and audio in general, and the idea of a mod tracker player is something I've thought about for a while. I always thought that mixing in real time would be doable and seems like you've achieved it!

Simon
This is super interesting - thanks for resurrecting the thread Simon, can't believe I missed it.

If you're looking at VGM playback then Tricky & I discussed this on the retro software forum: http://www.retrosoftware.co.uk/forum/vi ... f=19&t=982.

I got something running in BeebAsm that was reasonable but I wasn't entirely happy with the result and always planned to go back to it. I'm actually currently trying to get Julian Brown's vgm player assembled & running from his Beeb crtc demo.

I also need to follow up on my promise to add VGM logging back into B-Em (or BeebEm) so I can archive all the old Beeb music in a platform agnostic format.
Bitshifters Collective | Retro Code & Demos for BBC Micro & Acorn computers | https://bitshifters.github.io/

User avatar
simonm
Posts: 316
Joined: Mon May 09, 2016 3:40 pm
Contact:

Re: Beeb MOD Player

Post by simonm » Wed May 11, 2016 1:51 am

Fascinating stuff Sarah, thanks for sharing! I think for a humble 2Mhz 8-bit machine that's quite a feat.
Kieran - I think I've been on a similar odyssey to you guys! That link is a good read.
I stumbled on the VGM player in the CRTC demo and also your player too. Both very cool. I liked how you integrated exomizer, that was a neat idea. I think a lot of cool tunes will fit into a SWR bank this way.
My approach so far was to write a python script to parse VGMs, and see if I could optimize them a bit for realtime use, even if it was slightly lossy.
The first optimization was to quantize the data to 50Hz intervals, and remove any redundant volume/tone register writes. For more complex chip tunes, this does save a bit of space as there's fewer wait commands knocking around, plus we only need to use the single byte wait command every 20ms, reducing 3-byte commands to just 1. It also makes playback simpler as you can just hook onto the vsync interrupt.
So far this is working, and only the more complex chiptunes (with loads of fast efx) sound a bit choppy in places, not terribly noticeable tho.
The second optimization I have in mind is to just tokenize the stream (as you guys discussed), particularly the tone writes as they can take upto 5 bytes per write in VGM land.
Then I think with your exomizer unpacking in place, it'll be a bit more realistic to use VGM streams in demos/games etc.
The main setback is the different SN76849 clock speeds as you noted, so I'm having a chin scratch atm on the best way to pre-process tone data from non-beeb VGM chip tunes.

I love the idea of sequenced samples tho. I wondered if a 6502 2nd processor could be used to pep things up a bit? Just for fun like ;)
Is there a hard upper limit on the output sample rate for the beebs sound chip?

User avatar
tricky
Posts: 4800
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: Beeb MOD Player

Post by tricky » Wed May 11, 2016 8:05 am

The upper limit is probably limited by the 8us wait period that you are supposed to leave between signaling each byte on the slow data bus (to the sound chip) and un-signaling and the need to use all three channels to get more volume.

User avatar
kieranhj
Posts: 923
Joined: Sat Sep 19, 2015 11:11 pm
Location: Farnham, Surrey, UK
Contact:

Re: Beeb MOD Player

Post by kieranhj » Wed May 11, 2016 8:52 am

simonm wrote: My approach so far was to write a python script to parse VGMs, and see if I could optimize them a bit for realtime use, even if it was slightly lossy.
The first optimization was to quantize the data to 50Hz intervals, and remove any redundant volume/tone register writes. For more complex chip tunes, this does save a bit of space as there's fewer wait commands knocking around, plus we only need to use the single byte wait command every 20ms, reducing 3-byte commands to just 1. It also makes playback simpler as you can just hook onto the vsync interrupt.
So far this is working, and only the more complex chiptunes (with loads of fast efx) sound a bit choppy in places, not terribly noticeable tho.
The second optimization I have in mind is to just tokenize the stream (as you guys discussed), particularly the tone writes as they can take upto 5 bytes per write in VGM land.
Then I think with your exomizer unpacking in place, it'll be a bit more realistic to use VGM streams in demos/games etc.
The main setback is the different SN76849 clock speeds as you noted, so I'm having a chin scratch atm on the best way to pre-process tone data from non-beeb VGM chip tunes.
Nice. I'd love to take a look at the optimiser and have a listen to some of the tracks - I was collecting the most interesting / complex ones from BotB. The one main issue with my VGM player is that it completely hogs the Timer 1 with latches so is no use for demos / games and has no predictability on when the code is going to run. Fixing everything to the vsync is much more sensible!

My original goal was to be able to play VGM files natively without any preprocessing step (a *VGMPLAY command, if you will) but given the size of most of the files this would require a paging from disk scheme that I didn't get round to implementing. Once you've gone the trouble of preprocessing with Exomizer to compress the files you might as well optimise them for run-time playback so no need to stick to VGM format.

I didn't look into fixing up the clock speed issue but I naively assumed this would be a case of converting the VGM data into an actual frequency value from the source SN clock rate and then converting this into a data value at the Beeb SN clock rate. Using the calculation on page 376 of the AUG.
Bitshifters Collective | Retro Code & Demos for BBC Micro & Acorn computers | https://bitshifters.github.io/

User avatar
tricky
Posts: 4800
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: Beeb MOD Player

Post by tricky » Wed May 11, 2016 1:00 pm

If you look at the viewer I posted near the top of the thread mentioned above, it does the note frequency conversion - just a simple multiply and divide ;with a little rounding for good measure.

User avatar
simonm
Posts: 316
Joined: Mon May 09, 2016 3:40 pm
Contact:

Re: Beeb MOD Player

Post by simonm » Wed May 11, 2016 1:27 pm

tricky wrote:If you look at the viewer I posted near the top of the thread mentioned above, it does the note frequency conversion - just a simple multiply and divide ;with a little rounding for good measure.
Awesome, thanks! I'll take a look.
I've attached a VGM I converted to 60Hz initially, and run through Kieran's player. Sounds pretty nice, it's just a bit pitchy from the original.
Attachments
vgmplay.zip
VGM player playing non-Beeb chip tune
(14.73 KiB) Downloaded 41 times

User avatar
simonm
Posts: 316
Joined: Mon May 09, 2016 3:40 pm
Contact:

Re: Beeb MOD Player

Post by simonm » Wed May 11, 2016 11:06 pm

Ok managed to get the pitch re-tuned for beeb clock speed and thats ok, but any tunes that use the periodic noise as a bass effect is proving tricky.
I've detuned channel 2 by a futher 6.25% if the volume is off on channel2 and channel 3 is playing periodic noise to compensate for the missing bit in the shift register, and it's ALMOST there, but still sounds ever so slightly annoyingly out of tune!

User avatar
kieranhj
Posts: 923
Joined: Sat Sep 19, 2015 11:11 pm
Location: Farnham, Surrey, UK
Contact:

Re: Beeb MOD Player

Post by kieranhj » Thu May 12, 2016 7:05 am

Look forward to hearing the results!

I'm halfway through porting Julian's VGM player source to BeebAsm as I can't get his pasta assembler to build on my Windows machine (he's a Linux guy it would seem.) The OCAML parser / compressor appears to work fine with other VGM files, I just can't test what they sound like yet. Will post an update when I have it, would be nice to have another reference point.
Bitshifters Collective | Retro Code & Demos for BBC Micro & Acorn computers | https://bitshifters.github.io/

User avatar
simonm
Posts: 316
Joined: Mon May 09, 2016 3:40 pm
Contact:

Re: Beeb MOD Player

Post by simonm » Thu May 12, 2016 11:06 am

Hmm.. really scratching my head with this periodic noise re-tuning bit, so any more brains on this would be super helpful. It seems a general application of 6.25% detune isn't correct (tuning is out at lower notes, correct in mid-range and out on higher notes).

Here's how I understand things:
If the noise register channel 3 is set to mode 0 (bit 2 == 0) the SN outputs periodic noise from the shift register.
If the noise register tone is set to 3 (bits 1 and 0 = 1) then the periodic noise is influenced by whatever frequency is set on channel 2.
On the Beeb, the PN shift register used 15 bits, whereas on other systems it used 16 bits - so this is what needs adjusting for.

So I presume the shift register in PN mode generates 1 pulse per 15 clocks, but how does that get modulated by the channel 2 frequency?

Is there a way to calculate the relationship in Hz between the tone register value on channel 2 and the resulting Hz output from the periodic noise generator?

What would you set channel 2 frequency to, to get a given Hz PN output on Channel 3? If I can figure that, I'll be able to apply the necessary corrections.

I've scoured google land for docs on this but found nothing helpful.

User avatar
simonm
Posts: 316
Joined: Mon May 09, 2016 3:40 pm
Contact:

Re: Beeb MOD Player

Post by simonm » Thu May 12, 2016 11:18 am

I'm thinking I should probably take this chat over to the RS forums? How do you guys choose which board to post on? Is RS more suited for tech chats?

User avatar
BigEd
Posts: 3575
Joined: Sun Jan 24, 2010 10:24 am
Location: West Country
Contact:

Re: Beeb MOD Player

Post by BigEd » Thu May 12, 2016 11:22 am

Just a thought, but have you looked at other emulators, like for example jsbeeb?
https://github.com/mattgodbolt/jsbeeb/s ... 93&q=noise

User avatar
simonm
Posts: 316
Joined: Mon May 09, 2016 3:40 pm
Contact:

Re: Beeb MOD Player

Post by simonm » Thu May 12, 2016 12:55 pm

It's a good thought. I've studied a few SN emulation implementations (not the jsbeeb one so far tho, so thats handy too), but they tend to focus on simulating outputs at the chip level, and I confess I'm no expert audio/hardware engineer so getting from emulated code to frequency adjustments is proving to be a gap in my comprehension of all this.

User avatar
tricky
Posts: 4800
Joined: Tue Jun 21, 2011 9:25 am
Contact:

Re: Beeb MOD Player

Post by tricky » Thu May 12, 2016 8:35 pm

I nearly always end up recording a wav and then comparing samples in Audacity or similar as I can't translate what I hear into numbers!

User avatar
simonm
Posts: 316
Joined: Mon May 09, 2016 3:40 pm
Contact:

Re: Beeb MOD Player

Post by simonm » Thu May 12, 2016 9:18 pm

Its a tempting idea. I think I'll do something like this; or maybe synthesize a VGM with some specific test tones in it.
FWIW I've narrowed the problem down to the shift register being 15 bits on a beeb rather than 16 - if I export my NTSC VGM retuned at 4Mhz but leaving the shift register as 16-bit it sounds fine (on a VGM player, not a beeb). In theory the correction should be:

Code: Select all

original frequency
-------------------------------------
(15/16) * source clock / target clock
And although this sounds *almost* right, it's just not quite there. #-o

I've re-read the SN specs here http://www.smspower.org/Development/SN76489 and got a slightly deeper understanding now; in the tuned periodic noise mode, it just uses the tone frequency value in channel 2 the a reset counter for the waveform, rather than a fixed counter.

I have also discovered that due to the integer precision, theres a few top end frequencies that cant be mapped between a chip clocked @ NTSC and one clocked @ 4Mhz, but it's only a small set of values (ie. values < eight) so in practice that wont affect fidelity of most tunes.

User avatar
Rich Talbot-Watkins
Posts: 1679
Joined: Thu Jan 13, 2005 5:20 pm
Location: Palma, Mallorca
Contact:

Re: Beeb MOD Player

Post by Rich Talbot-Watkins » Thu May 12, 2016 10:07 pm

I think it's basically like this:

Normally the pitch value stored in a channel register in the sound chip specifies how many cycles before the output is inverted. So if you're at pitch 500, it'll output 500 cycles of 0 followed by 500 cycles of 1 (then scaled by the volume). The exception is pitch value 0 which is treated as if it were 1024.

Tuned periodic noise uses the counters in the same way, but instead of inverting the output each time, it just outputs a n cycles of 1 followed by n*14 cycles of 0.

This can actually be generalised as a special case of the noise implementation, which uses an array of 15 bits in conjunction with a linear feedback shift register to determine which level it should output each time.

The SMS document is pretty much spot on although it refers to a slightly different version of the sound chip which used a 16 bit linear feedback register. John Kortink's article here is a pretty accurate dissection of the chip behaviour.

User avatar
simonm
Posts: 316
Joined: Mon May 09, 2016 3:40 pm
Contact:

Re: Beeb MOD Player

Post by simonm » Thu May 12, 2016 10:24 pm

Nice one Rich, thanks for the extra insight.
Annoyingly, my test VGM sounds pitch perfect. Maybe the VGM I'm working with (admittedly quite a complex tune) has some other state I'm somehow processing incorrectly. Hmmm.... this wasn't supposed to take so much of my time up... ! Fun tho.
Attachments
vgmplay.zip
(1.7 KiB) Downloaded 35 times

Post Reply

Return to “new projects and releases: demoscene”