Elk Player

new graphics/music demos - bitshifters, 0xc0de, The Master + others
User avatar
Negative Charge
Posts: 93
Joined: Sat Jan 16, 2021 1:35 pm
Contact:

Elk Player

Post by Negative Charge »

Hello everyone. First post here, and my first 6502 asm program.

I grew up with an Electron, and like most Electron owners I was always a little disappointed with the sound in many games, envious of friends with C64s and later versions of the Spectrum. I always felt the Electron was capable of far more, even with it’s single channel sound and no volume control. Nick Pelling showed us the potential of the machine with the Pugwash theme, and Martin Galway’s music for Galaforce on the Electron was a great step in the right direction.

35 years ago I didn’t have the skill or knowledge to take my idea forward, but having been inspired by the work of 0xC0DE and simondotm on Elk Bad Apple I recently decided to see what could be achieved when accessing the ULA directly.

The result was better than I could have expected. The Elk will never match the musical output of the Beeb, but it’s been a good learning experience (even if my 6502 asm could do with a lot of improvement).

I’ve basically implemented an arpeggiator, and developed a rather convoluted tool chain to convert various other VGM formats into a pre-processed format the player can work with. If/when I’ve simplified that I’ll share the code - too many manual steps depending on the source material at the moment.

Hearing the Galaforce title music in pseudo 3-channel sound for the first time coming out of the Electron rather than hearing the three channels played in sequence (as with the original game) was worth the effort. Hearing Rob Hubbard’s Commando theme coming out of my Electron was pure joy (even if it is a pale imitation of the original SID).

Note: I used Elkulator to develop this, and have had it running on my Electron with ElkSD64. As it plays fast and loose with the memory map I’m not sure how it work on machines with other expansions. I think ElectrEm is working too now, although I did initially have some sound distortion issues.

I’ve tried to make this work on the Beeb emulators too, but the only one that produces sound anywhere near what I’d expect is B-Em, but the pitch table I’m using quickly goes out of tune at higher frequencies. If anyone is able to help fix that it would be most appreciated - I’ve tried many different tables, and even recorded the frequencies output by the Elk in an attempt to fix this but it’s still not working properly. B2 and JSBeeb only output noise, so I’m most likely doing something very wrong accessing the SN76489. I have no Beeb hardware to test this on.

I’ve put a few videos up on YouTube to demonstrate what the player is capable of here: https://m.youtube.com/channel/UCy7-RCo ... roA/videos

...and I’ve started uploading the first set of albums (.ssd’s) to run on the emulators or real Elk hardware here:
https://github.com/NegativeCharge/Releases

I hope the BitShifters don’t mind me converting some of their Beeb Tracker material - it’s been a big source of inspiration, as has b-tracker that was posted here recently. Also a big thanks to the emulator authors and all the contributors of code to this forum - without this resource I doubt I would have made much progress.

There’s a lot I’d like to do with this if I have the time - interrupt-driven, visualisations, accurate timing. Always interested in feedback on how I can improve the code - my asm knowledge is still very basic so there are most likely a lot of optimisations I could make.

— Negative Charge
User avatar
davidb
Posts: 3398
Joined: Sun Nov 11, 2007 10:11 pm
Contact:

Re: Elk Player

Post by davidb »

I noticed your videos a few days ago. The Commando theme is particularly impressive and captures something of the original - it's certainly a recognisable version. :D The Galaforce theme is also an interesting conversion.

Did anyone else notice the videos from Wouter Hobers on YouTube, particularly Acorn Electron plays Monkey Island 1 theme | better :)? I wonder what you think of that.
User avatar
0xC0DE
Posts: 1303
Joined: Tue Mar 19, 2019 7:52 pm
Location: The Netherlands
Contact:

Re: Elk Player

Post by 0xC0DE »

Great stuff! =D> And welcome to the forum!
0xC0DE
"I program my home computer / Beam myself into the future"
:arrow: Follow me on Twitter
:arrow: Visit my YouTube channel featuring my games and demos for Acorn Electron and BBC Micro
User avatar
kieranhj
Posts: 1104
Joined: Sat Sep 19, 2015 11:11 pm
Location: Farnham, Surrey, UK
Contact:

Re: Elk Player

Post by kieranhj »

Negative Charge wrote: Sat Mar 06, 2021 5:17 pm I hope the BitShifters don’t mind me converting some of their Beeb Tracker material - it’s been a big source of inspiration, as has b-tracker that was posted here recently. Also a big thanks to the emulator authors and all the contributors of code to this forum - without this resource I doubt I would have made much progress.
We don't mind at all! In fact we're really happy that our music discs have inspired you. :) This is really impressive work for the Elk, great job! =D> I particularly like the way Super Locomotive came out - really suits the arpeggio style. Between you and 0xC0DE could this be the beginning of an Electron-dedicated demo group!?!? 8)
Bitshifters Collective | Retro Code & Demos for BBC Micro & Acorn computers | https://bitshifters.github.io/
User avatar
Negative Charge
Posts: 93
Joined: Sat Jan 16, 2021 1:35 pm
Contact:

Re: Elk Player

Post by Negative Charge »

davidb wrote: Sat Mar 06, 2021 5:58 pm Did anyone else notice the videos from Wouter Hobers on YouTube, particularly Acorn Electron plays Monkey Island 1 theme | better :)? I wonder what you think of that.
Thanks - The Monkey Island theme was one of the first tunes I started experimenting with as the freq/duration data is readily available from many sources, and can be played back using regular sound/envelope commands - I think I initially used Silas Brown’s MIDI Beeper project for this. I uploaded my version to GitHub if you’re interested. There’s also a video here: https://youtu.be/js-YdPOtYtw
User avatar
Negative Charge
Posts: 93
Joined: Sat Jan 16, 2021 1:35 pm
Contact:

Re: Elk Player

Post by Negative Charge »

kieranhj wrote: Sat Mar 06, 2021 7:56 pm I particularly like the way Super Locomotive came out - really suits the arpeggio style.
Thank you. I’m pretty happy with how that one converted considering the source was the arcade VGM that uses 2xSN76489 - I thought there would be too many simultaneous notes playing for the arpeggiation to work, but stripping out the noise channels gave a better result than I expected. I converted it for comparison with the conversion of both Stryker’s Run theme and Daley Thompson’s both by Martin Galway. All have a unique quality to them, but I still prefer the Stryker’s Run version due to its nostalgic value.
User avatar
daveejhitchins
Posts: 7886
Joined: Wed Jun 13, 2012 6:23 pm
Location: Newton Aycliffe, County Durham
Contact:

Re: Elk Player

Post by daveejhitchins »

Welcome to the Forum, Negative Charge . . . Enjoy . . .

Brilliant work on the electron Sound =D>

Dave H.
Available: ARA II : ARA III-JR/PR : ABR : AP5 : AP6 : ABE : ATI : MGC : Plus 1 Support ROM : Plus 3 2nd DA : Prime's Plus 3 ROM/RAM : Pegasus 400 : Prime's MRB : ARCIN32 : Cross-32
User avatar
davidb
Posts: 3398
Joined: Sun Nov 11, 2007 10:11 pm
Contact:

Re: Elk Player

Post by davidb »

Negative Charge wrote: Sun Mar 07, 2021 6:56 am Thanks - The Monkey Island theme was one of the first tunes I started experimenting with as the freq/duration data is readily available from many sources, and can be played back using regular sound/envelope commands - I think I initially used Silas Brown’s MIDI Beeper project for this. I uploaded my version to GitHub if you’re interested. There’s also a video here: https://youtu.be/js-YdPOtYtw
I'm not incredibly familiar with the original, but that sounds like a good conversion, I think. :D

I'm impressed by how much you've managed to do with this approach.
User avatar
simonm
Posts: 363
Joined: Mon May 09, 2016 3:40 pm
Contact:

Re: Elk Player

Post by simonm »

davidb wrote: Sun Mar 07, 2021 3:14 pm I'm impressed by how much you've managed to do with this approach.
Me too - its not trivial to take a piece of 4-channel multi-volume music and render it as a fixed volume single square wave output!

FWIW I've uploaded my script that I used for 0xC0DE's Bad Apple Electron demo to Github here:
https://github.com/simondotm/vgm2electron

It worked ok for that tune, but other tunes not so much - Negative Charge's results are much better. =D>
User avatar
Negative Charge
Posts: 93
Joined: Sat Jan 16, 2021 1:35 pm
Contact:

Re: Elk Player

Post by Negative Charge »

simonm wrote: Sun Mar 07, 2021 5:15 pm [
Me too - its not trivial to take a piece of 4-channel multi-volume music and render it as a fixed volume single square wave output!

FWIW I've uploaded my script that I used for 0xC0DE's Bad Apple Electron demo to Github here:
https://github.com/simondotm/vgm2electron
Thanks - I’m really just standing on the shoulders of giants here... yourself included. I’m using MIDI as an intermediate format as most files can be converted to it - SID, AY, PIT, VGM etc. I can then drop the high and low frequencies outside the octave range of the Electron, unfortunately losing any bass-line or percussion. Once down-converted to 3 channels and using various tools such as BaWaMI I can output an arpeggio as a PIT dump which is then easy to convert to frequency/duration data and transpose / clamp as necessary. Some formats convert better than others.

I’d love to see your script - getting a 404 Not Found from the link you posted though. I uploaded a conversion of your BitShifters Beeb Tracker 3 music disc earlier today - quite strange hearing the Sonic soundtrack coming out of an Electron, but all in all it converted pretty well. Had to split over two SSDs due to the 31 entry DFS limit.
User avatar
simonm
Posts: 363
Joined: Mon May 09, 2016 3:40 pm
Contact:

Re: Elk Player

Post by simonm »

Negative Charge wrote: Sun Mar 07, 2021 8:06 pm I’d love to see your script - getting a 404 Not Found from the link you posted though.
Woops! Had repo set to private, it is now public!
User avatar
simonm
Posts: 363
Joined: Mon May 09, 2016 3:40 pm
Contact:

Re: Elk Player

Post by simonm »

Since there's more folks looking at this repo than just me now, I've added some better readme notes to help explain the script a little better. I'm sure that between us all we can keep levelling up Electron music to a whole new level of awesomeness! Shared brains ftw :lol:
Last edited by simonm on Mon Mar 08, 2021 3:45 pm, edited 1 time in total.
User avatar
simonm
Posts: 363
Joined: Mon May 09, 2016 3:40 pm
Contact:

Re: Elk Player

Post by simonm »

Negative Charge wrote: Sun Mar 07, 2021 8:06 pm I can then drop the high and low frequencies outside the octave range of the Electron, unfortunately losing any bass-line or percussion. Once down-converted to 3 channels and using various tools such as BaWaMI I can output an arpeggio as a PIT dump which is then easy to convert to frequency/duration data and transpose / clamp as necessary. Some formats convert better than others.
FWIW in case you're possibly filtering bass notes unnecessarily (as I did initially), I found the beeper frequency range is 122Hz to 31Khz - not 244Hz to 62Khz as the EAUG states. If anyone can confirm that would be good to be definitive on as I dont have an Electron to prove anything; all I know is that the Bad Apple conversion worked with this Hz range (and would have sounded much more tinny and unfaithful without that low end 122-244hz bass octave range)

EDIT: it now occurs to me that the 244Hz stated in the EAUG is likely just the counter inversion frequency, so for square waves the duty cycle is half of that of course.
User avatar
0xC0DE
Posts: 1303
Joined: Tue Mar 19, 2019 7:52 pm
Location: The Netherlands
Contact:

Re: Elk Player

Post by 0xC0DE »

Thanks for sharing your tool, Simon.

About the Electron:

Freq = 1 MHz / [32 * (n + 1)], or: n = [1 MHz / (32 * Freq)] - 1
e.g. ?&FE06=0 --> 31250Hz
?&FE06=255 --> 122Hz

Incidentally, it is quite easy to convert this to a Beeb value (single channel):

Beeb Tone 1 low = (((elkval+1)<<2) and &0f) or &c0
Beeb Tone 1 high = (elkval+1)>>2
0xC0DE
"I program my home computer / Beam myself into the future"
:arrow: Follow me on Twitter
:arrow: Visit my YouTube channel featuring my games and demos for Acorn Electron and BBC Micro
User avatar
Negative Charge
Posts: 93
Joined: Sat Jan 16, 2021 1:35 pm
Contact:

Re: Elk Player

Post by Negative Charge »

simonm wrote: Mon Mar 08, 2021 3:43 pm FWIW in case you're possibly filtering bass notes unnecessarily (as I did initially), I found the beeper frequency range is 122Hz to 31Khz - not 244Hz to 62Khz as the EAUG states. If anyone can confirm that would be good to be definitive on as I dont have an Electron to prove anything; all I know is that the Bad Apple conversion worked with this Hz range (and would have sounded much more tinny and unfaithful without that low end 122-244hz bass octave range)

EDIT: it now occurs to me that the 244Hz stated in the EAUG is likely just the counter inversion frequency, so for square waves the duty cycle is half of that of course.
Thanks Simon for posting your Python script - lots of useful techniques in there. I see a couple of similar approaches in raising the octave level of lower frequencies and lowering for high frequencies. I had some success with that, but ended up trampling over the mid range quite a bit. I'm filtering below 121Hz which isn't a problem for some material, but C64 SIDs tend to make use of as low as 60Hz for bass lines and like to use the full range.

I've just had a go at converting the Bad Apple VGM in your repo - was quite a tricky one to work with, but this is what I ended up with - https://youtu.be/WRzQSirIlDA - Not as clean as your version, but a reasonably faithful conversion. I need to work on more accurate timing loops as it sounds a little fast.
User avatar
Negative Charge
Posts: 93
Joined: Sat Jan 16, 2021 1:35 pm
Contact:

Re: Elk Player

Post by Negative Charge »

0xC0DE wrote: Mon Mar 08, 2021 4:50 pm Thanks for sharing your tool, Simon.

About the Electron:

Freq = 1 MHz / [32 * (n + 1)], or: n = [1 MHz / (32 * Freq)] - 1
e.g. ?&FE06=0 --> 31250Hz
?&FE06=255 --> 122Hz

Incidentally, it is quite easy to convert this to a Beeb value (single channel):

Beeb Tone 1 low = (((elkval+1)<<2) and &0f) or &c0
Beeb Tone 1 high = (elkval+1)>>2
Thanks for posting that! It may solve the completely out of tune higher frequencies I get when trying to play the same data file on a Beeb emulator. I'll give that a go.
User avatar
0xC0DE
Posts: 1303
Joined: Tue Mar 19, 2019 7:52 pm
Location: The Netherlands
Contact:

Re: Elk Player

Post by 0xC0DE »

Negative Charge wrote: Mon Mar 08, 2021 5:15 pm
simonm wrote: Mon Mar 08, 2021 3:43 pm FWIW in case you're possibly filtering bass notes unnecessarily (as I did initially), I found the beeper frequency range is 122Hz to 31Khz - not 244Hz to 62Khz as the EAUG states. If anyone can confirm that would be good to be definitive on as I dont have an Electron to prove anything; all I know is that the Bad Apple conversion worked with this Hz range (and would have sounded much more tinny and unfaithful without that low end 122-244hz bass octave range)

EDIT: it now occurs to me that the 244Hz stated in the EAUG is likely just the counter inversion frequency, so for square waves the duty cycle is half of that of course.
Thanks Simon for posting your Python script - lots of useful techniques in there. I see a couple of similar approaches in raising the octave level of lower frequencies and lowering for high frequencies. I had some success with that, but ended up trampling over the mid range quite a bit. I'm filtering below 121Hz which isn't a problem for some material, but C64 SIDs tend to make use of as low as 60Hz for bass lines and like to use the full range.

I've just had a go at converting the Bad Apple VGM in your repo - was quite a tricky one to work with, but this is what I ended up with - https://youtu.be/WRzQSirIlDA - Not as clean as your version, but a reasonably faithful conversion. I need to work on more accurate timing loops as it sounds a little fast.
I am liking this!
Are you syncing writes to &FE06 at 50Hz or 100Hz?
0xC0DE
"I program my home computer / Beam myself into the future"
:arrow: Follow me on Twitter
:arrow: Visit my YouTube channel featuring my games and demos for Acorn Electron and BBC Micro
User avatar
Negative Charge
Posts: 93
Joined: Sat Jan 16, 2021 1:35 pm
Contact:

Re: Elk Player

Post by Negative Charge »

0xC0DE wrote: Mon Mar 08, 2021 5:20 pm I am liking this!
Are you syncing writes to &FE06 at 50Hz or 100Hz?
Thanks - unfortunately neither at the moment. It's a simple delay loop based on code I found on these forums:

Code: Select all

.wait	
    {
        LDA durationlo
        JSR delay
        SEC
        SBC #$01
        STA durationlo
        LDA durationhi
        SBC #$00
        STA durationhi
        
        LDA durationlo
        CMP #&00
        BNE wait
        LDA durationhi
        CMP #&00
        BNE wait

        RTS
    }

    .delay
    {
        LDY	delayinc

    .dloop2	
        LDX	delayinc

    .dloop1	
        DEX
        BNE	dloop1
        DEY
        NOP
        NOP
        NOP
        NOP
        BNE	dloop2
        RTS
    }
User avatar
0xC0DE
Posts: 1303
Joined: Tue Mar 19, 2019 7:52 pm
Location: The Netherlands
Contact:

Re: Elk Player

Post by 0xC0DE »

Negative Charge wrote: Mon Mar 08, 2021 5:37 pm
0xC0DE wrote: Mon Mar 08, 2021 5:20 pm I am liking this!
Are you syncing writes to &FE06 at 50Hz or 100Hz?
Thanks - unfortunately neither at the moment. It's a simple delay loop based on code I found on these forums:

Code: Select all

.wait	
    {
        LDA durationlo
        JSR delay
        SEC
        SBC #$01
        STA durationlo
        LDA durationhi
        SBC #$00
        STA durationhi
        
        LDA durationlo
        CMP #&00
        BNE wait
        LDA durationhi
        CMP #&00
        BNE wait

        RTS
    }

    .delay
    {
        LDY	delayinc

    .dloop2	
        LDX	delayinc

    .dloop1	
        DEX
        BNE	dloop1
        DEY
        NOP
        NOP
        NOP
        NOP
        BNE	dloop2
        RTS
    }
Maybe get rid of that delay loop and do the following just before writing your next value to &FE06:

Code: Select all

  lda &240
.wait
  cmp &240
  beq wait
That''s the equivalent of a *FX19, i.e. wait for DisplayEnd interrupt (which triggers at 50Hz).
0xC0DE
"I program my home computer / Beam myself into the future"
:arrow: Follow me on Twitter
:arrow: Visit my YouTube channel featuring my games and demos for Acorn Electron and BBC Micro
User avatar
simonm
Posts: 363
Joined: Mon May 09, 2016 3:40 pm
Contact:

Re: Elk Player

Post by simonm »

Negative Charge wrote: Mon Mar 08, 2021 5:15 pm Thanks Simon for posting your Python script - lots of useful techniques in there.
No worries, bouncing ideas around means the Elk music scene will only get better!
Negative Charge wrote: Mon Mar 08, 2021 5:15 pm I see a couple of similar approaches in raising the octave level of lower frequencies and lowering for high frequencies. I had some success with that, but ended up trampling over the mid range quite a bit. I'm filtering below 121Hz which isn't a problem for some material, but C64 SIDs tend to make use of as low as 60Hz for bass lines and like to use the full range.
I know exactly what you mean as I found the transposing was occasionally imperfect, but I've tended to prefer transposition over lost notes. The missing low end is a perpetual problem of mine with chiptunes - even the BBC's SN76489 clocked at 4Mhz means a fair bit less bass range to match other PSGs.

The other subjective bit I found is deciding where to clamp/filter a note volume, since some softer notes in a tune can usefully contribute to the output beeper version whereas others can detract if treated as non-zero-volume = playing. Tricky!
Negative Charge wrote: Mon Mar 08, 2021 5:15 pm I've just had a go at converting the Bad Apple VGM in your repo - was quite a tricky one to work with, but this is what I ended up with - https://youtu.be/WRzQSirIlDA - Not as clean as your version, but a reasonably faithful conversion. I need to work on more accurate timing loops as it sounds a little fast.
Fascinating how spirited your version is, and how the different approaches give a different feel to the beeper music. I suspect there might be a couple of tuning issues in your conversion process as a few notes seemed slightly out here and there; but I know it's tricky or even always possible to get them spot on with only 8 bits of logarithmic precision!
0xC0DE wrote: Mon Mar 08, 2021 5:20 pm Are you syncing writes to &FE06 at 50Hz or 100Hz?
Thats a great question, I have wondered if 100Hz output would soften up some rough edges, but I was feared of generating vast amounts of ULA data. That said, the data does seem to compress quite well though. :-k
User avatar
Negative Charge
Posts: 93
Joined: Sat Jan 16, 2021 1:35 pm
Contact:

Re: Elk Player

Post by Negative Charge »

0xC0DE wrote: Mon Mar 08, 2021 4:50 pm Incidentally, it is quite easy to convert this to a Beeb value (single channel):

Beeb Tone 1 low = (((elkval+1)<<2) and &0f) or &c0
Beeb Tone 1 high = (elkval+1)>>2
I tried your formula to generate a note table (64 entries) with a conversion of the values I send to FE06. Although the higher frequencies sound in tune, the lower frequencies are still noticeably out of tune in B-em. If you have time would you mind taking a quick glance over the following table and see if I’ve calculated this correctly please?

Thanks for your other advice too. I’ll see if I can implement the sync to 50Hz next.

Code: Select all

EQUB %11001100,%00111101
EQUB %11001100,%00111001
EQUB %11001000,%00110110
EQUB %11000100,%00110011
EQUB %11001000,%00110000
EQUB %11001000,%00101101
EQUB %11000000,%00101010
EQUB %11000000,%00101000
EQUB %11001000,%00100110
EQUB %11000100,%00100100
EQUB %11000100,%00100010
EQUB %11000100,%00100000
EQUB %11001100,%00011110
EQUB %11001100,%00011100
EQUB %11000100,%00011011
EQUB %11001000,%00011001
EQUB %11000100,%00011000
EQUB %11001100,%00010110
EQUB %11001000,%00010101
EQUB %11001000,%00010100
EQUB %11000100,%00010011
EQUB %11000000,%00010001
EQUB %11000000,%00010000
EQUB %11000000,%00001111
EQUB %11000100,%00001111
EQUB %11000100,%00001110
EQUB %11001000,%00001101
EQUB %11001100,%00001100
EQUB %11000000,%00001011
EQUB %11000100,%00001011
EQUB %11001100,%00001010
EQUB %11000100,%00001010
EQUB %11001000,%00001001
EQUB %11000000,%00001000
EQUB %11001000,%00001000
EQUB %11000000,%00000111
EQUB %11001000,%00000111
EQUB %11000000,%00000110
EQUB %11001100,%00000110
EQUB %11000100,%00000110
EQUB %11000000,%00000101
EQUB %11001000,%00000101
EQUB %11000100,%00000101
EQUB %11000000,%00000100
EQUB %11001100,%00000100
EQUB %11001000,%00000100
EQUB %11000100,%00000100
EQUB %11000000,%00000011
EQUB %11001100,%00000011
EQUB %11001000,%00000011
EQUB %11000100,%00000011
EQUB %11000000,%00000010
EQUB %11000000,%00000010
EQUB %11001100,%00000010
EQUB %11001000,%00000010
EQUB %11001000,%00000010
EQUB %11000100,%00000010
EQUB %11000100,%00000010
EQUB %11000000,%00000001
EQUB %11000000,%00000001
EQUB %11001100,%00000001
EQUB %11001100,%00000001
EQUB %11001000,%00000001
EQUB %11001000,%00000001
User avatar
Negative Charge
Posts: 93
Joined: Sat Jan 16, 2021 1:35 pm
Contact:

Re: Elk Player

Post by Negative Charge »

simonm wrote: Mon Mar 08, 2021 5:49 pm I suspect there might be a couple of tuning issues in your conversion process as a few notes seemed slightly out here and there; but I know it's tricky or even always possible to get them spot on with only 8 bits of logarithmic precision!
You’re most likely right - the approach I normally use didn’t work well leaving lots of artifacts, so I used an alternate tool to convert from VGM to the intermediate MIDI file. That one usually produces worse results, but in this instance it was better at picking up the melody. It’s also the first video I’ve recorded from ElectrEm - I normally use Elkulator, but I think it might be slightly less accurate in reproducing the desired sound.
User avatar
0xC0DE
Posts: 1303
Joined: Tue Mar 19, 2019 7:52 pm
Location: The Netherlands
Contact:

Re: Elk Player

Post by 0xC0DE »

Negative Charge wrote: Mon Mar 08, 2021 7:34 pm
0xC0DE wrote: Mon Mar 08, 2021 4:50 pm Incidentally, it is quite easy to convert this to a Beeb value (single channel):

Beeb Tone 1 low = (((elkval+1)<<2) and &0f) or &c0
Beeb Tone 1 high = (elkval+1)>>2
I tried your formula to generate a note table (64 entries) with a conversion of the values I send to FE06. Although the higher frequencies sound in tune, the lower frequencies are still noticeably out of tune in B-em. If you have time would you mind taking a quick glance over the following table and see if I’ve calculated this correctly please?

Thanks for your other advice too. I’ll see if I can implement the sync to 50Hz next.

Code: Select all

EQUB %11001100,%00111101
EQUB %11001100,%00111001
EQUB %11001000,%00110110
EQUB %11000100,%00110011
EQUB %11001000,%00110000
EQUB %11001000,%00101101
EQUB %11000000,%00101010
EQUB %11000000,%00101000
EQUB %11001000,%00100110
EQUB %11000100,%00100100
EQUB %11000100,%00100010
EQUB %11000100,%00100000
EQUB %11001100,%00011110
EQUB %11001100,%00011100
EQUB %11000100,%00011011
EQUB %11001000,%00011001
EQUB %11000100,%00011000
EQUB %11001100,%00010110
EQUB %11001000,%00010101
EQUB %11001000,%00010100
EQUB %11000100,%00010011
EQUB %11000000,%00010001
EQUB %11000000,%00010000
EQUB %11000000,%00001111
EQUB %11000100,%00001111
EQUB %11000100,%00001110
EQUB %11001000,%00001101
EQUB %11001100,%00001100
EQUB %11000000,%00001011
EQUB %11000100,%00001011
EQUB %11001100,%00001010
EQUB %11000100,%00001010
EQUB %11001000,%00001001
EQUB %11000000,%00001000
EQUB %11001000,%00001000
EQUB %11000000,%00000111
EQUB %11001000,%00000111
EQUB %11000000,%00000110
EQUB %11001100,%00000110
EQUB %11000100,%00000110
EQUB %11000000,%00000101
EQUB %11001000,%00000101
EQUB %11000100,%00000101
EQUB %11000000,%00000100
EQUB %11001100,%00000100
EQUB %11001000,%00000100
EQUB %11000100,%00000100
EQUB %11000000,%00000011
EQUB %11001100,%00000011
EQUB %11001000,%00000011
EQUB %11000100,%00000011
EQUB %11000000,%00000010
EQUB %11000000,%00000010
EQUB %11001100,%00000010
EQUB %11001000,%00000010
EQUB %11001000,%00000010
EQUB %11000100,%00000010
EQUB %11000100,%00000010
EQUB %11000000,%00000001
EQUB %11000000,%00000001
EQUB %11001100,%00000001
EQUB %11001100,%00000001
EQUB %11001000,%00000001
EQUB %11001000,%00000001
Instead of using a table, use this:

Code: Select all

  
  ; A = value that you would write to &FE06 on an Elk
  clc
  adc #1
  pha
  asl a
  asl a
  and #&0f
  ora #&c0
  jsr write_sound_chip ; low 4 bits of frequency
  pla
  lsr a
  lsr a
  jsr write_sound_chip ; high 6 bits of frequency
Assuming you have something of a write_sound_chip function yourself ;)

I haven't checked all possible frequencies but I use this for sound in my games and it sounds okay to me.
0xC0DE
"I program my home computer / Beam myself into the future"
:arrow: Follow me on Twitter
:arrow: Visit my YouTube channel featuring my games and demos for Acorn Electron and BBC Micro
User avatar
Negative Charge
Posts: 93
Joined: Sat Jan 16, 2021 1:35 pm
Contact:

Re: Elk Player

Post by Negative Charge »

0xC0DE wrote: Mon Mar 08, 2021 7:46 pm Instead of using a table, use this:

Code: Select all

  
  ; A = value that you would write to &FE06 on an Elk
  clc
  adc #1
  pha
  asl a
  asl a
  and #&0f
  ora #&c0
  jsr write_sound_chip ; low 4 bits of frequency
  pla
  lsr a
  lsr a
  jsr write_sound_chip ; high 6 bits of frequency
Assuming you have something of a write_sound_chip function yourself ;)

I haven't checked all possible frequencies but I use this for sound in my games and it sounds okay to me.
Genius! =D> That’s fixed the issue. Now I need to go back and recompile every one of my .SSDs, remove the Acorn Electron only warning and re-upload them to GitHub. Thank you very much. This one has been bugging me for several weeks!
User avatar
0xC0DE
Posts: 1303
Joined: Tue Mar 19, 2019 7:52 pm
Location: The Netherlands
Contact:

Re: Elk Player

Post by 0xC0DE »

I'm glad that worked! 8)
0xC0DE
"I program my home computer / Beam myself into the future"
:arrow: Follow me on Twitter
:arrow: Visit my YouTube channel featuring my games and demos for Acorn Electron and BBC Micro
User avatar
Negative Charge
Posts: 93
Joined: Sat Jan 16, 2021 1:35 pm
Contact:

Re: Elk Player

Post by Negative Charge »

All disc images at https://github.com/NegativeCharge/Releases updated to allow playback on the BBC Micro. I don't have any physical Beeb hardware to test on, but appears to now be working fine in all of the emulators.

There are a couple of discs that won't work correctly on the Beeb due to inaccuracies in my timing algorithm which mean that System Beeps and a couple of tracks such as Xenon 2 on the David Whittaker disc play back too slowly. I'm working on fixing that thanks to advice from 0xC0DE and will re-upload once working correctly. The BBC Micro music disc also may not work on all machines as the Crazee Rider track uses large amounts of memory which means even compressed with Exomizer it needs to be loaded at &1190 rather than &2000. If I get round to moving the menu to assembler, that may eventually work too.

If anyone is able to test and confirm these work on physical Beeb hardware, that would be most appreciated. Thanks.
User avatar
Negative Charge
Posts: 93
Joined: Sat Jan 16, 2021 1:35 pm
Contact:

Re: Elk Player

Post by Negative Charge »

0xC0DE wrote: Mon Mar 08, 2021 5:45 pm Maybe get rid of that delay loop and do the following just before writing your next value to &FE06:

Code: Select all

  lda &240
.wait
  cmp &240
  beq wait
That''s the equivalent of a *FX19, i.e. wait for DisplayEnd interrupt (which triggers at 50Hz).
Thanks for this. Although the note duration is now consistent on both the Elk and Beeb, it’s playing at half speed. Unfortunately I can’t just divide the duration by 2 as the tune data is at 100Hz resolution. I guess it’s time to try and tackle use of the 100Hz interval timer.
User avatar
Arcadian
Site Admin
Posts: 4225
Joined: Fri Nov 24, 2000 12:16 pm
Contact:

Re: Elk Player

Post by Arcadian »

These are breathtaking - I downloaded them all yesterday and have been amazed by what I've heard so far. I wonder if any of the game soundtracks could be 'hacked' into the original Elk versions of the games?!

Anyway, I've just sent you a PM about tonight's Dev Night ... and have enabled your PMs too so you can actually reply! ;)
Please subscribe to the ABug YouTube channel!
User avatar
Negative Charge
Posts: 93
Joined: Sat Jan 16, 2021 1:35 pm
Contact:

Re: Elk Player

Post by Negative Charge »

Negative Charge wrote: Tue Mar 09, 2021 7:05 am
0xC0DE wrote: Mon Mar 08, 2021 5:45 pm Maybe get rid of that delay loop and do the following just before writing your next value to &FE06:

Code: Select all

  lda &240
.wait
  cmp &240
  beq wait
That''s the equivalent of a *FX19, i.e. wait for DisplayEnd interrupt (which triggers at 50Hz).
Thanks for this. Although the note duration is now consistent on both the Elk and Beeb, it’s playing at half speed. Unfortunately I can’t just divide the duration by 2 as the tune data is at 100Hz resolution. I guess it’s time to try and tackle use of the 100Hz interval timer.
Now sync'd the 100Hz interval timer - the note duration is a lot more consistent:

https://youtu.be/G7S3sLTcrRg

I have a 50Hz version of the track working against the DisplayEnd interrupt, but it loses some of its character due to the loss of a significant number of notes. Just need to incorporate this test back into the player and see how well it works with the other tracks. This temporarily breaks Model B compatibility, but it's working fine on the Elk and a Master.
Post Reply

Return to “new projects and releases: demoscene”