Shop OBEX P1 Docs P2 Docs Learn Events
MOD-player on Propeller — Parallax Forums

MOD-player on Propeller

overclockedoverclocked 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.

Comments

  • RaymanRayman Posts: 14,632
    edited 2014-09-04 06:01
    I'm no expert, but mod appears to be a simple wavetable with PCM data. So, I think it should be fairly simple to implement.
    I've seen other wavetable players here but don't remember one for .mod format...
  • Ahle2Ahle2 Posts: 1,179
    edited 2014-09-04 14:19
    It wouldn't be very hard at all and the quality (read sample rate) would be exellent because of the simplicity of the Paula in the Amiga. (it's technically waaaay simpler than the SID)
    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 :)
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2014-09-04 14:43
    My personal favorite was always Klisje Paa Klisje. It would be awesome to hear the Propeller Chip playing this.

    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
  • RaymanRayman Posts: 14,632
    edited 2014-09-04 17:26
    How much memory does it need?
    Is this memory to hold all of the various wavetables?

    Would some particular song not need all the wavetables?
  • roglohrogloh Posts: 5,786
    edited 2014-09-04 17:39
    This also has been of interest to me over the last year. It was actually on my todo list to attempt it on one of my projects and I spent some early time investigating mod playing requirements a while back but now I am diverted onto other things like DE0-nanos. It looked very tight but it just may be doable via streaming samples from a fast SDCARD for perhaps a 2-4 channel mod at decent sample rates. You need lots of COGs and it's a total real time/resource challenge to get it to fit on P1. It would be a fun and difficult project which is why I liked it. The only other way to go is with external RAM which would be simpler but perhaps wouldn't be so interesting or portable.

    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?
  • roglohrogloh Posts: 5,786
    edited 2014-09-04 17:41
    Rayman wrote: »
    How much memory does it need?
    Is this memory to hold all of the various wavetables?

    Would some particular song not need all the wavetables?

    Different songs need different amounts of memory, you are looking at upwards of 512k-1MB for a reasonable selection.
  • pik33pik33 Posts: 2,366
    edited 2014-09-05 01:48
    We have now p1v on DE2-115. It has sufficient memory to handle a mod. The longest Amiga (not PC xm etc) module I have has about 700 kB. Most of them are 50..200 kB
  • RaymanRayman Posts: 14,632
    edited 2014-09-05 02:57
    I see now the mod file contains both the wavetable samples and 4 channels of song data.
    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...
  • pik33pik33 Posts: 2,366
    edited 2014-09-05 03:19
    You can keep sample data in external memory. Track definitions are short and they can be keep in and interpreted from the hub ram.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2014-09-05 07:56
    Yeah, back then there was a need to keep things small because we all had dial-up access to a BBS. No internet at the time. Most of the samples were 8-bit and low sample rate/quality. Still very impressive for the time though. I myself made several tracker mods in my C= days. Some are on my website (what I could find after all these years). But I wanted to add that many games on the Amiga used tracker modules for the music. The format was very popular.
  • AribaAriba Posts: 2,690
    edited 2014-09-05 16:06
    rogloh wrote: »
    This also has been of interest to me over the last year. It was actually on my todo list to attempt it on one of my projects and I spent some early time investigating mod playing requirements a while back but now I am diverted onto other things like DE0-nanos. It looked very tight but it just may be doable via streaming samples from a fast SDCARD for perhaps a 2-4 channel mod at decent sample rates. You need lots of COGs and it's a total real time/resource challenge to get it to fit on P1. It would be a fun and difficult project which is why I liked it. The only other way to go is with external RAM which would be simpler but perhaps wouldn't be so interesting or portable.

    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?

    The link has to go directly to my harddisk, perhaps the NSA can help you with that :smile:

    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.

    Enjoy
    Andy
  • AribaAriba Posts: 2,690
    edited 2014-09-05 23:19
    I've just noticed that the audio output on the Activity Board is totally overdriven with the default settings, so please try it with a reduced Master Volume (set constant M_Vol to 3 or 4).
    I need to find the version with sample interpolation, I remember the quality was a bit better...

    Andy
  • overclockedoverclocked Posts: 80
    edited 2014-09-05 23:40
    Your description sounds nice and thanks for sharing. I need to get my SD-Card connection sorted out before I can really test it.
  • roglohrogloh Posts: 5,786
    edited 2014-09-05 23:43
    Ariba wrote: »
    The link has to go directly to my harddisk, perhaps the NSA can help you with that :smile:Andy
    LOL
    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.

    Enjoy
    Andy

    Thanks Ariba! i'm going to take a look at it.
  • Oldbitcollector (Jeff)Oldbitcollector (Jeff) Posts: 8,091
    edited 2014-09-06 19:35
    Chris, is this what you are looking for?

    http://modarchive.org/index.php?request=view_by_moduleid&query=47057

    My personal favorite was always Klisje Paa Klisje. It would be awesome to hear the Propeller Chip playing this.

    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
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2014-09-06 20:03
    I have the .MOD file on my PC along with hundreds of others, including .XM, .S3M, etc. I just didn't realize there was a Propeller MOD player.
  • @Ariba

    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?

    Thanks
  • AribaAriba Posts: 2,690
    cbmeeks wrote: »
    @Ariba

    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?

    Thanks

    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.

    Andy
  • SPI-RAM might work for audio. I don't have any issues devoting an entire propeller for audio with its own 512K SRAM. But yeah, with 2 pins for audio out and maybe 2 pins for p1-to-p1 communication, I would have to latch some pins. Still worth it.

    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).

  • roglohrogloh Posts: 5,786
    edited 2017-07-28 09:51
    @Ariba,

    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.

    Thanks!
    Roger.
    ps. Also got your player working over the I2S bus too at its 62.5kHz sample rate.
  • Hi Roger

    I2s mod working on native propeller chip ?

    Is possible post this code ?

    Many thanks
  • @Ariba

    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 fsel I 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 bytemove(@fsel,@buff,31) in showFiles() to move 13 bytes instead of 31, everything still works fine. However, if I actually shrink the size of fsel to 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 fsel before buff in 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?

    Cheers,
    Jesse

  • 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.

Sign In or Register to comment.