News:

Printed Amstrad Addict magazine announced, check it out here!

Main Menu
avatar_redbox

Arkos Tracker player with Digidrums

Started by redbox, 19:38, 30 July 13

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

redbox

I've created a Digidrum player for Arkos Tracker (by mashing the old StarKos player and Arkos Player together) as one wasn't available.  I also wanted to sort out the sample file types so new samples could be imported.

The samples played on the CPC are in 8-bit, 8Khz, mono, Raw (headerless) PCM format.  I've imported a couple from the Amiga as an example (a big fat 909 Kick and classic 808 snare).  I used Cool Edit Pro (defunct PC sound editor but still available on torrent) to convert them because Audacity/Sox etc didn't have the right file formats or options.

Included in the attached ZIP file are the following files:

digidrums.asm - the main player with examples preloaded - just load it into the WinAPE assembler and run (F9)

ArkosTrackerPlayer_CPCStable_MSX_edit.asm - Arkos Player with an inserted RETurn so the digidrum routine can do it's stuff if required and call back
LXCESSAK.BIN - Arkos Tracker BINary export
808sn1.pcm - Example converted sample
909Kick.pcm - Example converted sample
Lxcess.aks - Arkos Tracker file for the PC which you can edit (digidrum triggers are in the SpTrk)

You'll see the routine takes a whole frame to play the sample, but there is a flag which you can read so you can wait until a digidrum is not playing to do your stuff - which would be useful if playing digidrums on a menu screen or something similar.  As for anything else, I'll have to write a DMA version ;)

TFM

Ha! Maybe an "new official release" soon?
Great work!
TFM of FutureSoft
Also visit the CPC and Plus users favorite OS: FutureOS - The Revolution on CPC6128 and 6128Plus

arnoldemu

#2
Does it mix the sample playing with the music playback routine to get a more correct sample playback?

I know that for digidrums it's ok not to mix the samples, but for other sounds it could result in some distortion.

EDIT: Looking at the code, yes the sample is played seperately from the player and not mixed with it.
EDIT: Still this remains a great player and thank you for publishing the code.
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

redbox

Quote from: arnoldemu on 08:51, 31 July 13
Does it mix the sample playing with the music playback routine to get a more correct sample playback?
I know that for digidrums it's ok not to mix the samples, but for other sounds it could result in some distortion.

Can you explain what you mean and I'll look at implementing it...?

redbox

Quote from: arnoldemu on 08:51, 31 July 13
Does it mix the sample playing with the music playback routine to get a more correct sample playback?

Okay, after looking further I see that both Digitracker and Protracker mix 3 channels of samples into one channel for playback.  I expect this is because of the Z80 processor speed limitation (without DMA).

So I assume they both use some kind of look-up table (similar to a mask table) to blend the samples?  And that this approach could be used with normal AY sounds (e.g. when using digidrums)...?

I also see that they both use 4-bit samples at 14.4hz... how is this possible?  When I've played samples the CPC could only manage 8hz per frame...?

arnoldemu

#5
Quote from: redbox on 11:01, 31 July 13
Can you explain what you mean and I'll look at implementing it...?
So the current way you have it working:

The player takes x lines. You check if the digi effect should be played and you play this for x lines (with nops to setup the timing).

Now, to get it correct, the digi effect should be played on *every* line. The player code then needs to be interleaved so it takes the remaining cycles on the lines it is active on.

It's quite a bit of work and head aches. May be best to make a c program to work it out.

Digidrums can work without this because they have noise, but if you have a clean/pure/lighter sound, you may hear it as distortion.

Next thing I would like to see if you could do it ;) would be to implement the digi play back using DMA ;)

That would help with a game I have sitting waiting to be finished off ;) It would be nice to have it use AY for 2 channels and 1 channel is digi (drums or otherwise).
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

arnoldemu

Quote from: redbox on 11:10, 16 August 13
Okay, after looking further I see that both Digitracker and Protracker mix 3 channels of samples into one channel for playback.  I expect this is because of the Z80 processor speed limitation (without DMA).

So I assume they both use some kind of look-up table (similar to a mask table) to blend the samples?  And that this approach could be used with normal AY sounds (e.g. when using digidrums)...?

I also see that they both use 4-bit samples at 14.4hz... how is this possible?  When I've played samples the CPC could only manage 8hz per frame...?
I can play at 15Khz, by sending a volume each line, but that doesn't include the mixing. I'm guessing the routine is similar to my last post where it mixes it with the playback code.
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

redbox

Quote from: arnoldemu on 11:24, 16 August 13
Now, to get it correct, the digi effect should be played on *every* line. The player code then needs to be interleaved so it takes the remaining cycles on the lines it is active on.

Ahhh, I see.  I will try this.

So how does this increase the sound quality?  Because you are playing the sample and player at the same time, instead of just cutting the channel to play the sample?  But wouldn't playing the AY on the same line cancel out the sample you've just played...?

Quote from: arnoldemu on 11:24, 16 August 13
Next thing I would like to see if you could do it ;) would be to implement the digi play back using DMA ;)

This is ultimately what I am working towards as I'd like DMA routines for my Plus project, and will of course share anything I come up with :)

Quote from: arnoldemu on 11:24, 16 August 13
It would be nice to have it use AY for 2 channels and 1 channel is digi (drums or otherwise).

Agreed - most of the documented stuff is either pure AY or pure samples - not much inbetween.  So something working for classic CPC and Plus DMA would be very useful.

redbox

Quote from: arnoldemu on 11:24, 16 August 13
Next thing I would like to see if you could do it ;) would be to implement the digi play back using DMA ;)
That would help with a game I have sitting waiting to be finished off ;) It would be nice to have it use AY for 2 channels and 1 channel is digi (drums or otherwise).

Well after spending ages getting my head around the Arnold V Specification, I've finally managed to integrate DMA 'samples' into the Arkos Tracker player so you can have 2 AY channels and 1 DMA channel.

First thing I did is write a converter (convert_sample.asm) which takes a 8-bit, 15625Hz, Mono, Unsigned, Raw (headerless) PCM input file and turns it into the DMA 'sample' format.  The sample has to be hard-coded to the channel you want to play it back on because of the way the DMA 'queue' works.  The converter makes use of the LOAD/multiple PAUSE iteration trick so the resulting files aren't huge.

Then I changed the Arkos Player so that it can be edited to not alter the PSG registers on the channel you want to play DMA samples on.  If you don't do this, you get interference in the sample playback as the Arkos Player PSG output conflicts with the DMA.  Edit the file (arkos_player_psg.asm) to select the channel you're playing back your samples on (hard-coded from the converter previously).

Then input your Arkos Tracker exported BINary into the main player (dma_player.asm), assemble and run.  And you hear two channels of AY along with 15625hz samples being played by the DMA with no overhead  :D

I've included examples in the attached file so if you want to see (or hear) it in action then just assemble and run dma_player.asm .

All your DMA are belong to us  8)


arkos_player.asm - edited Arkos Player
arkos_player_psg.asm - editable file so you can choose the channel you play DMA samples on
convert_sample.asm - converts 8-bit, 15625Hz, Mono, Unsigned, Raw (headerless) PCM into DMA 'sample' format
dma_player.asm - the main player with examples preloaded - just load it into the WinAPE assembler and run (F9)
Lxcess_digidrums.aks - Arkos Tracker file for the PC which you can edit (digidrum triggers are in the SpTrk)
LXCESSAK.BIN - Arkos Tracker BINary export
samples/808sn1.pcm - original sample
samples/909Kick.pcm - original sample
samples/sample_dma_808sn1.asm - converted DMA sample
samples/sample_dma_909Kick.asm - converted DMA sample


Devilmarkus

as I'm not a CPC-coder, I'd be happy with a working DSK of this.
Could you add it, redbox?
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

arnoldemu

@redbox: Excellent! Exactly what I was after.
I would like a pc version of the sample conversion tool though ;) But I can make that.

Please can I use this in the MazeZam Plus cart game I mentioned in another thread?
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

redbox

Quote from: arnoldemu on 17:46, 20 August 13
@redbox: Excellent! Exactly what I was after.

Good news.  You might want to also play around some of the other PSG registers in the Arkos Player (e.g. maybe also kill the channel for DMA using reg7) but it's easy enough to do that with the example I've given.

Quote from: arnoldemu on 17:46, 20 August 13
I would like a pc version of the sample conversion tool though ;) But I can make that.

I thought about this but then it creates the problem of which language, where as we all speak Z80 here  ;)   But if you do write one please let me have a copy.

Quote from: arnoldemu on 17:46, 20 August 13
Please can I use this in the MazeZam Plus cart game I mentioned in another thread?

Yes of course, look forward to hearing it in action!

redbox

Quote from: Devilmarkus on 16:01, 20 August 13
as I'm not a CPC-coder, I'd be happy with a working DSK of this.
Could you add it, redbox?

Attached.  RUN"DMA

Devilmarkus

#13
Thankyou for compiling it.

For those of you who don't have a CPC+ Emulator (or the real machine):

Redbox's DMA Sound Test in JavaGX4000 Applet

You should add a nice piccy, Redbox! ;)
When you put your ear on a hot stove, you can smell how stupid you are ...

Amstrad CPC games in your webbrowser

JavaCPC Desktop Full Release

tastefulmrship

(from the CPC+ game proposal thread... originally as a PM)

Sir,
Firstly, here are the AY tunes I've done so far for Bill's Tomato Game... they're still at WinAPE volumes, but you get the general idea. Obviously, all drums can be replaced with tiny samples & a lot of the boring mono-tone tracks can be replaced with SID voice; to properly emulate the original tunes.
Some tunes also have Protracker tricks or instrument samples that are difficult to emulate on AY (woodblock in JUNGLE-1 & the water dripping in WATER-2, etc), so again, obvious places for samples.

However...
I've done some initial stuffs with samples, but when using larger samples (like voices or breakbeats) they were always being played too slowly. I always meant to look into it a lot more... but never got the time. I'll see what I can do with my current version of Believe (by Hollywood, BigJim & New Order) as it uses a large breakbeat & voice sample with your new player.

redbox

Quote from: tastefulmrship on 15:17, 07 September 13
Obviously, all drums can be replaced with tiny samples & a lot of the boring mono-tone tracks can be replaced with SID voice; to properly emulate the original tunes.

Well it seems the DMA can be used to emulate 'SID voices' quite nicely - there is documentation on the Quasar website.  It does sound nice in the Killmax demo and I seem to remember someone on this forum posting something to Soundcloud but I can't remember what now.

Still not sure how you'd create the SID voices you wanted though?  Unless you rip them from the ST (and even then, how do you get them out of a YM file for example)...?

Quote from: tastefulmrship on 15:17, 07 September 13
I've done some initial stuffs with samples, but when using larger samples (like voices or breakbeats) they were always being played too slowly. I always meant to look into it a lot more... but never got the time.

The replay speed is most likely wrong because the sample is at the wrong frequency.  If you have any samples you want to play on the CPC, then send them to me in the original format (i.e. WAV etc from PC or IFF etc from Amiga) and I'll convert them to DMA format for you.

tastefulmrship

Quote from: redbox on 18:46, 07 September 13
Well it seems the DMA can be used to emulate 'SID voices' quite nicely - there is documentation on the Quasar website.  It does sound nice in the Killmax demo and I seem to remember someone on this forum posting something to Soundcloud but I can't remember what now.

Still not sure how you'd create the SID voices you wanted though?  Unless you rip them from the ST (and even then, how do you get them out of a YM file for example)...?
Ummmm... yeah... I know that SID voice is something that a lot of real CPC musicians are waiting for and I reckon they're aware of the serious CPC load it takes on a CPCnorm, however, if it is possible to emulate the SID and play the "other" two channels within the frame (I guess that would require a huge 300Hz tune) then the ReSeT/Revision oldeskool music-compo could have some real C64 beaters! (Ok, I know Reed has already done that, but his tune was a standard 50Hz chiptune).

Anyway, this is me rambling again... in short; if it's possible to write a tracker/player that has SID sound (for either CPCnorm or CPC+), then I think this community would seriously appreciate that! Top man!

Quote from: redbox on 18:46, 07 September 13
The replay speed is most likely wrong because the sample is at the wrong frequency.  If you have any samples you want to play on the CPC, then send them to me in the original format (i.e. WAV etc from PC or IFF etc from Amiga) and I'll convert them to DMA format for you.
Ok, if it's alright with you, I'll start with BELIEVE (by HOLLYWOOD & BIGJIM). Attached is my original AY version; no samples, no drums, just the bare tune... and it sounds pretty boring (in comparison to the original .mod)

Also attached are the two samples; the breakbeat and the voice. The voice is easy to attach (once converted) as it's played on it's own!
The issue I have is with the 4th channel, the breakbeat.

Initially, I was in talks with SyX to look into using the external digitiser to play the fourth channel; ie the CPC plays channels A, B & C as normal, but the player triggers the external hardware to play the sample (in this case, the breakbeat). This ensures that the sample-play routine doesn't interfere with one of the AY channels, but still emulates a 4-voice tune.
However, from what I gather from the CPC+ DMA player, you can get 4-voices from a 3-voice chip? Is this the case or am I just not understanding? If it is, then almost all .mod files are possible on CPC without external hardware. How cool is that?

Anyway, I'll attach the voice sample once converted to DMA and we'll take it from there.

Ta muchly! ^_^

redbox

Quote from: tastefulmrship on 11:48, 08 September 13
Anyway, this is me rambling again... in short; if it's possible to write a tracker/player that has SID sound (for either CPCnorm or CPC+), then I think this community would seriously appreciate that! Top man!

From the way I understand it works I think it's definitely possible for both the classic CPC and Plus.  However, playing samples and SID voices to any degree of accuracy on the normal CPC is super tricky because of the timing issues - you need a highly optimised player that interleaves between playing the samples/SID voices (and the Arkos/Starkos player isn't suited to this purpose).

So really, it's better with the Plus because you can also use the DMA which unloads some of the burden (definitely with samples, but with SID voices it's still a bit tricky if you want a good sound as the changes in volume etc have to occur a lot more often).  I think the best approach is to generate a good Plus player that works with Arkos (because it's what a lot of composers use) and work backwards to see how far you can get.

Quote from: tastefulmrship on 11:48, 08 September 13
However, from what I gather from the CPC+ DMA player, you can get 4-voices from a 3-voice chip? Is this the case or am I just not understanding? If it is, then almost all .mod files are possible on CPC without external hardware. How cool is that?

The DMA just feeds one of the AY channels with no overhead, so you don't have a 4th channel, just the same 3 AY channels.  The DMA can also feed all 3 channels at once (i.e. 3 samples playing).

The problem is that when playing a sample on one of the channels, you need to "shut the channel down" meaning that the music player routine doesn't try to send anything to the PSG as well - otherwise you get interference and it sounds bad.  In the player I posted above I just shut the whole channel down which is playing samples via the DMA completely (as it was just a 'proof of concept' player)... but if you want you can also play AY and DMA samples on a channel, but you need to know the length etc of the samples so you can time how long to shut it down for.

Thanks for the files - I can re-write the player routine with the tune and samples you've given me and I'll let you know how it sounds :)

redbox

Quote from: tastefulmrship on 15:17, 07 September 13
I've done some initial stuffs with samples, but when using larger samples (like voices or breakbeats) they were always being played too slowly. I always meant to look into it a lot more... but never got the time.

I had a look at the original Believe MOD and think I know that the problem you're having is.

On the Atari ST and CPC, samples are played at one pitch - hence why they are known as 'digidrums' because this type of playback is only really any good for percussion and isn't much use for other instruments which require pitch changes (piano, bass etc).

On the Amiga, you can play any sample at any pitch and gotcha is this includes drum sounds.  In the MOD you're using the breakbeat is being played at C-6 which is one octave higher than 'standard' pitch of C-5, hence why the exported sample sounds too slow.  The 'Believe' vocal is played at C-5 which is the standard pitch and so the sample sounds right.

But the good news is you can accommodate for this before importing the sample to the CPC for the DMA  :)

tastefulmrship

Quote from: redbox on 20:37, 08 September 13
I had a look at the original Believe MOD and think I know that the problem you're having is.

On the Atari ST and CPC, samples are played at one pitch - hence why they are known as 'digidrums' because this type of playback is only really any good for percussion and isn't much use for other instruments which require pitch changes (piano, bass etc).

On the Amiga, you can play any sample at any pitch and gotcha is this includes drum sounds.  In the MOD you're using the breakbeat is being played at C-6 which is one octave higher than 'standard' pitch of C-5, hence why the exported sample sounds too slow.  The 'Believe' vocal is played at C-5 which is the standard pitch and so the sample sounds right.
Ah yeah, my fault... I sent you the original breakbeat .wav file before I had time to resample it to the proper pitch (ie play the sample at C-6 in MODPlug while recording via WaveStudio. Not very high-tech, I know, but it usually works). If I get five minutes after work, I'll attach the new sample here.

redbox

Quote from: tastefulmrship on 08:34, 09 September 13
Ah yeah, my fault... I sent you the original breakbeat .wav file before I had time to resample it to the proper pitch (ie play the sample at C-6 in MODPlug while recording via WaveStudio. Not very high-tech, I know, but it usually works). If I get five minutes after work, I'll attach the new sample here.

No prob, I ripped the samples from the original MOD as to 'preserve' the original sound...!

I've got the breakbeat and vocal sample playing and attached is a demo (RUN"DISC).  The breakbeat sounds sweet but the vocal is a bit distorted (shows the limitations of having to convert 8-bit to 4-bit to work with the DMA).

I need to do some alterations to my DMA player before I include the AY sounds so that samples and AY can be played together on one channel somewhat.  I'll let you know how I get on, but I think your tracker file will need some rearranging too to get the best possible sound.

arnoldemu

How are you doing your 8-bit to 4-bit?
Are you using a logarithmic table?

There are other ways that the audio could be compressed. You could store the changes in volume - better for Plus DMA with it's pause etc.

To improve "audio quality" you may be able to double the frequency and insert an "average" sample between each "good" sample. Perhaps this may make it better?
My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

redbox

#22
Quote from: arnoldemu on 13:00, 09 September 13
How are you doing your 8-bit to 4-bit? Are you using a logarithmic table?

Yep, it's a logarithmic table:


convert_4bit_table:   
                defb      1, 1, 1, 1, 2, 3, 3, 4, 5, 5, 6, 7, 7, 7, 7, 8
                defb      8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9
                defb     10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11
                defb     11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11
                defb     11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12
                defb     12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13
                defb     13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13
                defb     13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13
                defb     13,13,13,13,14,14,14,14,14,14,14,14,14,14,14,14
                defb     14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14
                defb     14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14
                defb     14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,15
                defb     15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15
                defb     15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15
                defb     15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15
                defb     15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15


Quote from: arnoldemu on 13:00, 09 September 13
There are other ways that the audio could be compressed. You could store the changes in volume - better for Plus DMA with it's pause etc.

Yep, I have made use of the PAUSE register because otherwise the DMA samples are huge.

Quote from: arnoldemu on 13:00, 09 September 13
To improve "audio quality" you may be able to double the frequency and insert an "average" sample between each "good" sample. Perhaps this may make it better?

The original samples are higher quality as they're coming from the Amiga (8-bit).  I converted the samples to 15625hz using PC software (Cool Edit Pro) and this does process them as you've described above. It's just that some samples sound much better at 4-bit (synth drums for example) than others (voice etc).  The nice sinus waves of clean synth drums also compress better than voice samples because of the logarithmic values combined with the PAUSE register use.

arnoldemu

cool ok.

Hmmm.. I wonder what can be done to improve the vocal samples...

My games. My Games
My website with coding examples: Unofficial Amstrad WWW Resource

redbox

Quote from: arnoldemu on 13:32, 09 September 13
Hmmm.. I wonder what can be done to improve the vocal samples...

Using samples that don't have a lot of reverb or other added 'noise' I think. 

Trial and error as always ;)

Powered by SMFPacks Menu Editor Mod