MOD-player on Propeller
overclocked Posts: 80
edited 2014-09-06 20:03 in Propeller 1
I've tried searching both forum and web but didn't find anything. Anyone tried implementing a Amiga Module player on the Propeller? Is it possible, any code available? How could one handle the samples? Streaming samples from SD-Card? using external SPI-SRAM?
Lets here what you experts has to say about this.
Lets here what you experts has to say about this.
I've seen other wavetable players here but don't remember one for .mod format...
If it had not been for the limited RAM in the Propeller, I would have done it long before SIDcog; Back in the days when the Propeller still was the coolest kitten in the neighbourhood. =^.^=
Ariba started implementing a tracker on the Propeller some years ago, that used a SD card as "sample RAM". I think it was supposed to be able to play standard Amiga Sountracker/Protracker modules.
Btw, when we are at it.... here is my favourite Amiga module
For that matter, long before there were tracker modules on the Amiga there was a program called, Sonix, and the demo song, "Jays Song" was very catchy. Here's a link: https://www.youtube.com/watch?v=ybZZXyZzOu0
Is this memory to hold all of the various wavetables?
Would some particular song not need all the wavetables?
I know it has been already been done for AVR chips. I think if someone can make it work from SD on a prop that would be a great challenge. Ahle2?
ps. I will have to see what Ariba did. Any links?
Different songs need different amounts of memory, you are looking at upwards of 512k-1MB for a reasonable selection.
Looks like there can be 32 wavetables, each up to 64 kB.
Does seem like external memory might make that a lot easier...
On the other hand audio is very slow and SD is fast...
The link has to go directly to my harddisk, perhaps the NSA can help you with that
My MOD player plays directly from SD card and uses one Spin cog to play the pattern, and one PASM cog for the sample player. There is also another cog for the fast SD card SPI routines, not sure if that also counts.
The pattern data needs 1 kB per pattern, and up to 64 patterns are possible, so you can hold only the current pattern to play in hub memory, the whole song is still on the SD card.
There are max. 31 instruments (single samples) each up to 64 kByte. Normally the samples are much shorter, so the whole sample memory is mostly under 250 kB.
The sample player must be able to play 4 samples at the same time and change pitch and volume of every channel. Also a part of the sample must be played in a loop.
There are some more informations in the RETRONITUS thread, also a screenshot of the Tracker. My intension was to make a Tracker and not just a MOD player, but I haven't finished the project because editing on the SD card was too hard. I think this needs a Propeller with min. 256 kB hub- or external RAM.
Because there seems to be some interest, I took the player part and added a very simple menu via a Terminal (P.S.T. or PropTerminal). The SD and audio pins can be defined in the CON section, the default setting is for the Activity Board.
Attached are 2 ZIP files. One containes the Spin files which you compile and load with the PropTool. Before that you need to extract the other ZIP to a fresh formated SD card. It holds a temp file and some MOD files.
The SD card should be fresh (fornated) because all the files needs to get consecutive sectors otherwise the sample player will not work correct.
But it anyway not works perfect, there is still a bug with the sample loops. I could not find the reason so far, so looped samples sound a bit bumpy or produce glitches.
I need to find the version with sample interpolation, I remember the quality was a bit better...
Thanks Ariba! i'm going to take a look at it.
Sorry to bring up an old thread. But, have you had any more progress on this? I would love to get a good MOD player going on a P1. I have 512K SRAM just waiting to play MOD's. :-D
Also, how many channels do you think could be played in one COG?
I have not worked on it since then. You know the Prop 2 would be the ideal processor for a MOD player ... and was only a few month away then
With 512kB SRAM connected to a Prop1 it should also be possible, but this needs about 29 pins! I planned to try it with an SPI-RAM (128kB) but too many other projects got in the way.
How many channels? Depends a lot on how fast you can access the samples and on the sample frequency you want. Maybe 4..8, the classical MODs need only 4 channels.
What I'd like to do is have my I/O Propeller load music from SD over to the audio Propeller's SRAM and the audio Propeller would just have to play it. So I wouldn't need SD support on the audio propeller. Just maybe 2-3 pins for serial.
Imagine 2 COGS running 4 channel Amiga MODS (8 channels) with 2 COGS running SID and maybe one COG running AY-3-8910.
That would rock (no pun intended).
Hey Andy, I know its been ages but I finally had a chance to try out your test MOD file player posted above since I was mucking about with all that I2S audio stuff recently. I got it working however you are right there seems to be some audio quality problems with it compared to listening to a normal player in VLC for example. Although some of that might well be due to my SD card read speed. Regardless it was cool to hear that classic retro sounding wavetable sample music of the old demoscene coming from a propeller.
When I get another chance to play about more I hope to code up something similar but either use SDRAM on P1V boards to hold larger audio samples or use my 1MB/2MB SRAM memory expansion board on the BeMicro MAX10 board for this. That 2MB should be more than suitable for holding pretty much any MOD/S3M file of interest, even 512kB-1M should be plenty for most songs.
The other option as you mentioned is to try some (Q)SPI SRAM but they seem to top out at 128kB for some reason which is rather small.
ps. Also got your player working over the I2S bus too at its 62.5kHz sample rate.
I2s mod working on native propeller chip ?
Is possible post this code ?
Sorry to dredge up an old thread, but I wanted say thanks for this code! I think I remember trying this years ago but am "re-discovering" it now and trying to understand some of the inner workings of it. There's one thing in particular that I'm having trouble understanding at the moment:
The 32-byte array
fselI think is just for holding the filename of the mod, correct? I think it could be as small as 13 bytes, no? (8.3 + 1 more for the null). Indeed, if I change the line
showFiles()to move 13 bytes instead of 31, everything still works fine. However, if I actually shrink the size of
fselto 13 bytes (or anything smaller than 32), the file appears to load without issue but doesn't play. It's probably right in front of me but I'm not seeing what the source of the issue is. I thought maybe the call to
popen()might've been writing something to it, but it doesn't look like it. Repositioning
buffin memory doesn't seem to affect it either (just in case something was writing to buff and writing past the end of it). Any ideas? Or am I misunderstanding fsel's purpose?
Without looking at the code, try 16 bytes. Maybe a byte array further down needs alignment.
Haven't yet worked out which array it is, but dang, yes - moving 16 bytes makes it function. I don't think I'd have ever worked that out hahah.