Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Native Sound Support for MOD, S3M, XM, IT and VOX (IMA ADPCM)

Author
Message
Xaby
FPSC Reloaded TGC Backer
17
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 19th Apr 2017 15:56 Edited at: 19th Apr 2017 15:58
Hallo AGK2-Fans,

first, it is not finished
why do I do this post?

I am interessted in playing Amiga modules in an App. Why MOD? Because the can be tiny, e.g. 50 kBytes for 3 min. music. So I could fit maybe about 4 hours of good music into 1 MB, insteat of about ~ 200 MB of OGG-Music or so.
There is a wrapper for AppGameKit with Windows https://forum.thegamecreators.com/thread/219423

MO3 would be nice, what is MO3? It is a combination of MOD-formats and OGG if you will. e.g. Bejeweled 2/3 music, playable with XM-Play http://support.xmplay.com/
http://www.futurecrew.com/skaven/tracker_music.shtml

What did I do so far? I used Turbo Pascal Code http://web.eject.co.za/gob/code/tp/modplayer.htm
And tried to understand


After working on translating and searching for other information, I was directed to FMODDOC, a documentation about creating a MOD-Player from FireLight (creator of FMOD)
http://www.filewatcher.com/m/fmoddoc2.zip.390839-0.html

With some research, there are also some descriptions about the other formats.

For creating S3M e.g. I am using Sound Club 2 for Windows. http://www.bluemoon.ee/history/scwin/index.html
And for texting MOD I am using DOSBOX and Sound Club 1 for DOS, because Sound Club for Windows has a bug with 64Bit Windows when creating a MOD, don't matter if 4, 8 Channels.
SoundClub for DOS http://www.bluemoon.ee/history/scdos/index.html
DosBox http://www.dosbox.com/download.php?main=1

Formats:

Modland music formats ftp://ftp.modland.com/pub/documents/format_documentation/

Tutorials by FireLight
MOD ftp://ftp.modland.com/pub/documents/format_documentation/FireLight%20MOD%20Player%20Tutorial.txt
S3M

other Formats
XM ftp://ftp.modland.com/pub/documents/format_documentation/FastTracker%202%20v2.04%20(.xm).html
IT ftp://ftp.modland.com/pub/documents/format_documentation/Impulse%20Tracker%20v2.04%20(.it).html

-----------------------------------------------------

First I wanted to create sound with SoundBuffers from scratch, like SFXR by Dr. Petter http://www.drpetter.se/project_sfxr.html
Or like Bfxr (AS3 Flash) http://www.bfxr.net/

But it is not music and for some sounds I could use these tools and create WAVE files. But for music, I had to write my own composer. So I realized, there are formats for that. Like Hively Tracker http://www.hivelytracker.co.uk/downl.php
It sounds great, and the tune is, what I was looking for. But is it flexible enough? I tested some MOD music with very tiny sizes and they can also sound great. So there is no need for creating the sound/noise with parameters in the program itself. I could use samples. And it does not matter if my music is about 5 kByte or 50 kByte, so my idea was, to support MOD.

Because of Sound Club 2 for Windows and the bug on x64 OS with saving MOD files, and the video above in C for S3M replayer, I began with S3M. But I didn't finished it. And in the S3M documentation later from FireLight I found, that it is better, to make a MOD-replayer first
And I like also, that XM files can get small like HVL / AHX files. But from the complexity, what I understand it is like:

MOD -> S3M -> XM -> IT

Before I would here a sound on my own replayer, it would be a lot of work. (I read, that it can be done in two days So maybe I am not as good in AppGameKit, or not concentrated enough)

That for I decided a simple format and translated C-code for the VOX-File format. AudaCity http://www.audacityteam.org/ can compress and decompress (encode / decode) VOX-files.
https://wiki.multimedia.cx/index.php/Dialogic_IMA_ADPCM

Why ADPCM? I saw that https://de.wikipedia.org/wiki/ADX_(Audio)
ADX is an audio format with looping audio in it and is compressed with ADPCM. The article says, that it is used in game music. And I know, that SNES and N64 are both able to play samples coded in ADPCM.

So ... I decided to create an ADPCM decoder/encoder. Compression would be 1:4, not as good as OGG, but it was only have the way, I would loop it later or so and could get my music about 500 kByte or 1 MB for files which would be like 3 or 5 MB as MP3/ogg

I tried to translate this code to AGK2 Tier 1 Basic
http://faculty.salina.k-state.edu/tim/software/vox/vox.html#the-standard

I was very proud, when I was able to decode VOX-files I created with Audacity. And later I encoded them. And it was great. I also could load it into AudaCity. It works a kind of.

You will see, that the wave-forms are not the same. So maybe in my VOX-code is somewhere a but

from up to down:
my vox-decoder, my vox-encoder, audacity encoder/original

Attachments

Login to view attachments
Xaby
FPSC Reloaded TGC Backer
17
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 19th Apr 2017 16:03 Edited at: 19th Apr 2017 16:16
So a lot of words, and no code
I can decode MOD / S3M header. But it is some work for the patterns. And there is still no sound.

First header, with XM-play to see, if I am on the right way


new layout, maybe for better tracking the tracks later



s3m, first try, a mess of code
vox, encoder / decoder, but I slowed it down with IMA / VOX ADPCM tests, and no header for IMA ADPCM Wave, so it is kind of useless
mod, ... it can load a mod header, but with out notes and not creating memblocks with the samples for the instruments

Maybe you are interessted in seeing the beginning. Or have some ideas. Or you feel motivated to decode one of the formats by yourself. Maybe we could make a "competition" or contribution like with the small game-themes. The reason for my posting here is, that I don't know, when I will have the time, to work on the replayer in the near future. (a really great, but very future format would be OPUS)

Attachments

Login to view attachments
Xaby
FPSC Reloaded TGC Backer
17
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 20th Apr 2017 14:49
30 Songs from Bejeweled 3 about 1 hour of music in 763 kBytes (MO3, ~ 700 kByte when you 7zip them)
https://modarchive.org/module.php?179344

~ about 20 min. ~ 2,5 MB
https://modarchive.org/module.php?179234

Maybe it would be interessting, if any interest is in nativ replayer lib?
Xaby
FPSC Reloaded TGC Backer
17
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 7th Dec 2018 22:42
re-opened, maybe for a community project?

feel free, to use the code above. It is not much, I was trying to read the header from S3M
puzzler2018
User Banned
Posted: 7th Dec 2018 23:44
Ive always loved to try and program a dancing spectrum analyser - with all frequencies having different levels so we can have things interact with those levels.

does this have something potential as such

Xaby
FPSC Reloaded TGC Backer
17
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 8th Dec 2018 14:43 Edited at: 8th Dec 2018 14:47


Since the transposing of notes or frequencies is simple math, you would also get out of the box a spectrum analyser, because you know already the "frequency" because you created the note before.
and showing of the wave form is also not that complicated, it is nearly Y as the value stored and X is the time.

You could look into my "try" to Encode / Decode ADPCM. There is someware an error, but it sounds nearly the same, because the human is not great in absolute volume or frequencies, but more in differences.

to write an converter from "S3M" without Adlib to a WAVE-form in memory would be "easy", more easy than playing it on the fly.



here is my "setup"

Using Sould Club V2 for Windows, it is free and came with build in samples for the instruments. It is also only about 3 MB including over 500 samples.
http://www.bluemoon.ee/history/scwin/

And it can export to WAV and S3M. The MOD export is some what broken, I guess. Because of Windows / DOS and 8 Bit / 16 Bit bugs or so.

The resulting S3M plays perfectly fine in XM Play.
http://support.xmplay.com/

So I created with SoundClub some easy Music. 1 voice, only one pattern. And try to decode it.
S3M contains the voices in 8 bit or 16 bit. And the voices itself have also some header.

I tried to "translate" the Pascal S3M-player code from the video, a PDF is also there, to AppGameKit Basic Tier 1.
If the S3M source code has Assembler code in it, I am screwed.

The next thing is, that I can't play a SoundBuffer directly from Memory. So I could create the complete Song and play that back as SoundBuffer with AGK.

But here comes the problem, let's say the S3M is about 200 kByte and is about 7 min. If we could play SoundBuffers directly and mix them together, we would have a memory-foodprint of about 200 kByte for our 7 min. + maybe some bytes for variables. Because the Voices are uncompressed in 8 Bit or 16 Bit.

But if we would "render" it out in CD-Quality. 44.1kHz and 16 Bit Stereo,

7 min. are 420 seconds. 16 Bit are two Bytes and Stereo would double the need in Memory.
And per second we have about 44100 samples (values in time with the amplitude)

44100 * 2 * 2 * 420 ~ 74088000 Bytes in Memory. ~ 70 MByte in Memory. for 7 min. so about 10 MB per minute music.
If we want to slide from one song to another, we would need both in memory. So about 140 MB, but maybe we only have 3 min. or so songs, than it would be also only about 70 MB.

The SNES, C64, MegaDrive, NES, Master System and so on, had a lot less memory. Also the Amiga and early DOS PCs. So they don't render the music completly into the memory.

Let's say, we have 32 Voices and every Voice is a AGK-SoundID. And we could play every Voice in its right pitch. But we would have to time it on a time-line somehow. Parallel. In the Background, another Thread maybe.




We also wouldn't need S3M and or very much individual samples / voices. We could have a hard coded stack of wave-samples. That would be nearly the same as with General MIDI and its Wave-Table.

Mario Paint Composer
http://www.mariomayhem.com/downloads/mario_paint_composer_download/

about 20 samples for the instrument voices. And the song-files are easy to "decode"

Attachments

Login to view attachments
Xaby
FPSC Reloaded TGC Backer
17
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 8th Dec 2018 17:16 Edited at: 8th Dec 2018 17:21
I found some code with in-line wave-samples as source-code
https://github.com/TeensyAudio/Wavetable-Synthesis/tree/master/Examples/GeneralMidiSynth

so:

4/4* (header)
++++++q:

every : block is a "note"-slot

between the + are the notes. 1 to 5 possible. Every note has its tune and its instrument. Mario is "a" as instrument, the ghost is "s". The tune c' is "o", the notes a counted from above. the highest tune is "a". I guess, it is C'''
So the note is two letters. first instrument and second the tune.

after the +++ pluses, 5 note slots, there is the volume. "q" is the highest volume. At the end of 96 note-slots "% and the tempo is the tempo like "%200 for tempo 200.

So it is possible to play 5 notes at the same time. The first MOD could play 4 notes at the same time because of the AMIGA Paula Sound chip. Later MOD "specifications" allowed more notes at the same time like 8.

It is also called channels or tracks. So in mod-language the Mario Paint Composer has 5 channels. And 20 voices. All the notes playing in the same lenght, I guess and only the Tempo would change the complete overall feel of the speed.


from here
https://www.tastenwelt.de/lesen/news/noten-lernen-jeder-kanns-und-es-ist-nie-zu-spaet/

A is 440 Hz, 2*A is 880 Hz in frequency or double the speed of the tune. (pitch)
puzzler2018
User Banned
Posted: 8th Dec 2018 19:54
Thanks Xaby - a lot of very useful information for future projects.

Xaby
FPSC Reloaded TGC Backer
17
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 9th Dec 2018 04:33 Edited at: 9th Dec 2018 04:34
And here it is, no editing, but a proof of concept. Sound-Samples have to be fixed. Maybe ripping it from the original later





feel free, to try it out. Sound samples are from SoundClub. I used C as base, not A, so the tune is not quite right. But it is here now 5:33 am, so I have to go to bed

Attachments

Login to view attachments
Jack
20
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 9th Dec 2018 07:59 Edited at: 9th Dec 2018 08:03
Mario Paint Composer in AppGameKit, so much win nice one xbaby!
nostalgia just shooting though my venes

"But it is here now 5:33 am, so I have to go to bed"
I know what u mean, the second dev marathon day is always the hardest

anyway, I ve attached u some piano samples that I recorded myself,
if you want to experiment with them. The zip contains 84 ongoing tones.
You can also use them in any AppGameKit example you post, in fact everyone does.
If you need some recordings, feel free to ask, as I also want to create some instrument samples for sharing.
I have a modern music studio at my workplace that is currently not in use, so I can record & edit some stuff.

[/url]

Attachments

Login to view attachments
Xaby
FPSC Reloaded TGC Backer
17
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 9th Dec 2018 11:48
@Jack,

yes, some CC0 samples for the AppGameKit version of Mario Paint Composer would be the biggest X-mas gift, I guess, you could make.
I guess, I also would have to change the symbols / icons. And also the title later

There is also somewhere a newer Mario Paint Composer out there, where the little Mario is jumping on the current tick. He is somehow the playhead.

The next thing, we could do, is to decode the 16-Bit sample part in S3M-music-files and try, to make a "real" tracker.

S3M has a lot of special effects, but at first, I wouldn't care too much. So the goal is not, to be 100% accurate and absolutly ProTracker 3 or so compatible. More like SoundClub 2 S3M without special effects.

MODule like S3M mostly contain one Sample, but it will be played part from the beginning and after some time, it will loop. So I guess, it would be possible, to make 2 AGK-SoundIDs out of that, and if the first SoundID is finished, the second starts playing with looping till it has to be shut off.
I don't really know, if the timing would work out, because in my mind that would work only every tick, but maybe the "Attack" is shorter or longer than one complete tick. And that would cause gab without sound.

So we would have to check more often. But okay, it could work, if we check every frame ... and if the "Attack" is over start playing the loop and if the tick is on time and "says" that the note is over, we look, which SoundID in this track is still playing and shut it off.

... so this is just the beginning.

MarioPaint Composer, S3M, MIDI ... the OUYA e.g. plays MIDI in Android 4.1 via AppGameKit without problems like a "video"-file or a "ogg"-file. But we could do more "dramatic" dynamic music with that and have nearly the same "wave-table" all over all devices.

Also don't tested MIDI on e.g. Raspberry Pi.

Thx, for the help.
Xaby
FPSC Reloaded TGC Backer
17
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 9th Dec 2018 15:34 Edited at: 9th Dec 2018 15:35
https://danielx.net/fxz-edit/

I found that, seems to be like SFXR and or BFXR,

so after S3M-decoding and "saving" the next thing would be / could be, to also generate the voices itself. With that, the "music-files" could be small like Hively-Tracker files. Let's say per voice to generate about under 100 bytes for its parameters. lets say 32 voices max. and that could be compressed as well. Maybe per voice only 16 Bytes and we have a song with 16 voices in total, that would be 256 Bytes for the voices.
And the rest would be for the tracks and notes. And if we don't use all 128 possible notes in 8 octaves, but only let's say 16 like in Mario Paint Composer, we only would need 4 Bits and 4 Bits maybe for the voice-ID. So 1 Byte and if we only use 4 tracks, that could be end up in 4 Bytes per tick without volume ...

so a pattern could easy be under 500 Bytes, let's say we have 10 patterns, so the music files would be about under 5 kByte big. And could play some minutes, depends on the pattern repetition and tempo. That could be easily be ~ 5 min. of music fit into 5kByte data.

Attachments

Login to view attachments
Xaby
FPSC Reloaded TGC Backer
17
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 10th Dec 2018 01:17 Edited at: 10th Dec 2018 01:19
Here is the Java-Source-Code of a forked Super Mario Paint Composer v.1.1.2.2
it has all the sprites in it and also the tunes, but the tunes are in SF2 SoundFont-Wavetable
Have to look, how to get it out there (I guess, there are some rip-programs or extractors, but maybe I could get AppGameKit to read it to a Memblock and created SoundIDs out of it ...)

https://github.com/SeymourSchlong/Super-Mario-Paint/releases/tag/v1.1.2.2-p

original
https://github.com/DC37/Super-Mario-Paint


Fork in Action


(side-note, this version of Mario Paint Composer has another save-theme or codec if you will. Not the +++++:+++++:++++ thingly, so the code for AppGameKit above reads only the other ones yet)

I guess, this week, I don't have time, to work on it, but feel free, to look into my code from the 7zip above and maybe you could tell me, how it could be a better way or so.

Thx.
Jack
20
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 10th Dec 2018 05:30
Just give me some sort of a list of instruments and information about the highest and lowest tone and I see what I can do.

[/url]
Xaby
FPSC Reloaded TGC Backer
17
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 10th Dec 2018 12:04
//--------------------------------
// We need 20 voices as instruments and somehow we have to make sure, that also 5 notes with the same instrument could be played
// Mario, Mushroom, Yoshi, Star, Flower, Gameboy, Dog, Cat, Pig, Swan, Baby, Plane, Boat, Car, Heart, Piranha, Coin, ShyGuy, Ghost
// sounds like (Sound Club 2 instruments used):
// Hard_Block, Low_Tom, Noisy_Escape-Melody, Glockenspiel-Melody, Short_Brass_Beep (C2), Slap_Brass_2 (C2), Dog, Cow (C2), OuchVoice, Orch_Hit_4, Ouch, Acustic_Guitar2, Open_HiHat_1, Fingered_El_Bass, Solo_Guitar, Grand_Piano, String_Swell, Muted_Guitar2
// Mushroom: Drum
// Gameboy: Beep-Sound
// Dog, Cat, Pig, Baby: like they sound
// Boat: drums and hihat
// Swan: Orchester hit
// Flower: Trumpet
// ShyGuy, Piranha, Heart, Ghost, Plane: Piano and Guitars

this it is at the moment
// h/b',C',D',E',F',G',A',HB,C'',D'',E'',F'',G'',A'',HB ,C''' // half-tunes will follow

one sample would be enough per voice, but the boat e.g. is different. It has about 2 or 3 samples, depends on the tune. (the boat is for drums)

it's about 2 octaves. But to have 3 would be nice, I guess.

for reference, I would use the A with 440 Hz. So all samples should be playing the A tune at 440 Hz.

The Coin-Sound we could create with SFXR or BFXR e.g.

Maybe I could integrate some "wave-table" switching. For serious music and more chip-tune like stuff. So we could have more than one set of voices.
Jack
20
Years of Service
User Offline
Joined: 4th Oct 2004
Location: [Germany]
Posted: 11th Dec 2018 09:41 Edited at: 11th Dec 2018 09:43
I recorded them from a yamaha sound chip emulator. It's the same like in the snes. Merry christmas.

You just need a function to modify the pitch of the sample in order to obtain another tone, sort of like the snes does.
Do it by loading them into memblocks, rewrite into another memblock with diffrent pitch and save it as another wav file.
You can actually create the whole player inside one memblock. You will also be capable of merging sounds.
I have work to do now, but when I return home, I search some old code, that may help.

[/url]

Attachments

Login to view attachments
Xaby
FPSC Reloaded TGC Backer
17
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 21st Dec 2018 22:08
Thx,

I hope, I find the time after christmas, to look more into that and do something more advanced with the "Mario Paint clone"-thingly I build so far. Will also look into native S3M and MOD, they seem to share some similarities.

Merry Christmas, also to you.
Xaby
FPSC Reloaded TGC Backer
17
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 27th Jan 2019 08:47
I found that channel on YouTube and it is inspireing. Also the Source Code is on GitHub, so maybe "we" could convert it to AppGameKit Tier 1 or at least to Tier 2.



I will also work some more time on a little Music Composer.
Xaby
FPSC Reloaded TGC Backer
17
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 29th Jan 2019 08:05
TTS in C++


Maybe we implement that as well and have some more options on all platforms. I know, there is some TTS implemented in AppGameKit, but it needs the plattform to have it installed before and also the voices are very limited.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 29th Jan 2019 20:14
Many moons ago, someone made a MOD tracker in DBP. I think it might've been Indi. Could be worth checking out.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
Xaby
FPSC Reloaded TGC Backer
17
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 31st Jan 2019 11:48
@Phaelax,

did you now, if the Source is available or if we could convert it to AppGameKit?
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 6th Feb 2019 16:18 Edited at: 6th Feb 2019 16:46
I'll have to do some digging. I don't think Indi is around the forums anymore, but VanB might've done a mod tracker at some point too.

Here's what I managed to find:


xGEKKOx
https://forum.thegamecreators.com/thread/210185

VanB
https://forum.thegamecreators.com/thread/3947
https://forum.thegamecreators.com/thread/11209

XANAX 2B
https://forum.thegamecreators.com/thread/59045
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
Xaby
FPSC Reloaded TGC Backer
17
Years of Service
User Offline
Joined: 17th Apr 2007
Location: Berlin
Posted: 11th Feb 2019 21:26
@Phaelax, sometimes the Source is not there :-( and the threads are older than 90 days :-( but we have in this board some people, who know there stuff, I guess


https://bisqwit.iki.fi/jutut/kuvat/programming_examples/doukutsu-org/

maybe we try this line by line to convert to AGK.

I also found this sites
https://github.com/ValeryAnisimovsky/GameMediaFormatsCoreFilters/tree/master/GMFCore
https://github.com/lclevy/unmo3/blob/master/spec/s3m.txt
https://github.com/TeensyAudio/Wavetable-Synthesis


http://www.elektronika.kvalitne.cz/ATMEL/S3Mplayer/S3Mplayer_eng.html
with a link to a ZIP with MOD-format documentation
http://www.elektronika.kvalitne.cz/ATMEL/S3Mplayer/doc/FH-MFDL2.ZIP

Login to post a reply

Server time is: 2024-11-23 04:54:00
Your offset time is: 2024-11-23 04:54:00