IonicWind Software

Aurora Compiler => Software Projects => Topic started by: Ionic Wind Support Team on January 02, 2006, 02:15:23 PM

Title: MOD player
Post by: Ionic Wind Support Team on January 02, 2006, 02:15:23 PM
A conversion of a conversion ;)

Attached to the bottom of this message is a zip file containing the mod player, bassmod.dll, a few sample mods and this source code.  If you wish to compile it yourself then you'll need to create the import library for bassmod.dll (it's on the tools menu).

Also included is the dialog file (mod.dlg) used to create the skeleton code of the initial app.

You will need the latest update to compile this.  (the second Alpha2 Rev 5 or greater).


#USE "BASSMOD.lib"
//A music MOD player 1/2/2006 Paul Turley - Ionic Wind Software
//BASSMOD.DLL must be in the same path as this program or in the system directory

DECLARE IMPORT,BASSMOD_MusicLoad(int mem,string name,int offset,int length,int flags),int;
DECLARE IMPORT,BASSMOD_Init(int device,int freq,int flags),int;
DECLARE IMPORT,BASSMOD_MusicPlay(),int;
DECLARE IMPORT,BASSMOD_MusicStop(),int;
DECLARE IMPORT,BASSMOD_MusicPause(),int;
DECLARE IMPORT,BASSMOD_MusicFree(),int;
DECLARE IMPORT,BASSMOD_Free(),int;
DECLARE IMPORT,BASSMOD_MusicGetName(),STRING;
DECLARE IMPORT,BASSMOD_MusicGetPosition(),INT;
DECLARE IMPORT,BASSMOD_MusicGetLength(int playlen),int;
DECLARE IMPORT,BASSMOD_MusicIsActive(),int;
DECLARE IMPORT,BASSMOD_MusicSetPosition(int pos),int;
DECLARE IMPORT,BASSMOD_GetVolume(),int;
DECLARE IMPORT,BASSMOD_SetVolume(int vol),int;


#define POSITION_SCROLL 1
#define BUTTON_PLAY 2
#define BUTTON_PAUSE 3
#define BUTTON_STOP 4
#define STATIC_5 5
#define STATIC_6 6
#define GROUP_7 7
#define VOLUME_SCROLL 8
#define GROUP_9 9
#define STATIC_10 10
#define EDIT_NAME 11
#define FREQ_1 12
#define FREQ_2 13
#define FREQ_3 14
#define GROUP_15 15
#define STATIC_PATTERN 16
#define STATIC_POSITION 17

def pos,pattern,vol,freq as int;
def filename,filter as string;


class dlg:CDialog
{
declare OnInitDialog(),int;
declare OnClose(),int;
declare OnControl(int nID, int nNotifyCode, unsigned int hControl),int;
declare OnMenuPick(int nID),int;
declare OnTimer(int nIDEvent),int;
declare OnHScroll(int nCommand,int nPos,int nID),int;
declare OnVScroll(int nCommand,int nPos,int nID),int;

}

global sub main()
{
filter = "MOD files|*.IT;*.XM;*.S3M;*.MTM;*.MOD;*.UMX";
dlg d1;
d1.Create(0,0,369,282,0x80C80080,0,"Mod Player",0);
d1.AddControl(CTSCROLLBAR,"",47,185,190,17,0x50000000,0x0,POSITION_SCROLL);
d1.AddControl(CTDEFBUTTON,"Play",27,227,70,20,0x5000000B,0x0,BUTTON_PLAY);
d1.AddControl(CTBUTTON,"Pause",108,227,70,20,0x50000000,0x0,BUTTON_PAUSE);
d1.AddControl(CTBUTTON,"Stop",187,227,70,20,0x50000000,0x0,BUTTON_STOP);
d1.AddControl(CTSTATIC,"Row",139,149,26,16,0x5000010B,0x0,STATIC_5);
d1.AddControl(CTSTATIC,"Pos",53,149,25,17,0x5000010B,0x0,STATIC_6);
d1.AddControl(CTGROUPBOX,"Transport",13,130,260,132,0x50000007,0x0,GROUP_7);
d1.AddControl(CTSCROLLBAR,"",310,70,17,180,0x50000001,0x0,VOLUME_SCROLL);
d1.AddControl(CTGROUPBOX,"Volume",286,52,69,211,0x50000007,0x0,GROUP_9);
d1.AddControl(CTSTATIC,"Name",8,14,42,18,0x5000010B,0x0,STATIC_10);
d1.AddControl(CTEDIT,"",49,12,213,21,0x50800800,0x200,EDIT_NAME);
d1.AddControl(CTRADIOBUTTON,"11025",26,61,59,20,0x50020009,0x0,FREQ_1);
d1.AddControl(CTRADIOBUTTON,"22050",26,81,57,20,0x50000009,0x0,FREQ_2);
d1.AddControl(CTRADIOBUTTON,"44100",26,101,58,20,0x50000009,0x0,FREQ_3);
d1.AddControl(CTGROUPBOX,"Sample Rate",13,49,85,76,0x50000007,0x0,GROUP_15);
d1.AddControl(CTSTATIC,"",79,149,34,19,0x50000100,0x0,STATIC_PATTERN);
d1.AddControl(CTSTATIC,"",170,149,38,17,0x50000100,0x0,STATIC_POSITION);
d1.DoModal();
d1.StopTimer();
BASSMOD_MusicFree();
BASSMOD_Free();

return 0;
}

dlg::OnClose(),int
{
CloseDialog(1);
return true;
}

dlg::OnInitDialog(),int
{

CButton *pButton;
CScrollBar *pScroll;
CMenu m;
m.BeginMenu();
m.MenuTitle("File");
m.MenuItem( "Load",0,2);
m.MenuItem( "Quit",0,1);
m.EndMenu();
SetMenu(m.Detach());
/* Initialize any controls here */
pButton = GetControl(FREQ_3); pButton->SetCheck(1);
freq = 44100;
vol = 100;
pScroll = GetControl(VOLUME_SCROLL); pScroll->SetScrollRange(0,100);
pScroll->SetScrollPos(0);
StartTimer(100);
CenterWindow();
return true;
}

dlg::OnControl(int nID, int nNotifyCode, unsigned int hControl),int
{
select nID
{
case BUTTON_PLAY:
if(nNotifyCode = 0)
{
BASSMOD_MusicPlay();
/*button clicked*/
}
case BUTTON_PAUSE:
if(nNotifyCode = 0)
{
BASSMOD_MusicPause();
/*button clicked*/
}
case BUTTON_STOP:
if(nNotifyCode = 0)
{
BASSMOD_MusicStop();
BASSMOD_MusicSetPosition(0);
/*button clicked*/
}
case FREQ_1:
case& FREQ_2:
case& FREQ_3:
CButton *pRadio = GetControl(FREQ_1);if(pRadio->GetCheck()) freq = 11025;
pRadio = GetControl(FREQ_2);if(pRadio->GetCheck()) freq = 22050;
pRadio = GetControl(FREQ_3);if(pRadio->GetCheck()) freq = 44100;
IF(BASSMOD_MusicIsActive())
{
BASSMOD_Free();
if(BASSMOD_Init(-1,freq,16)=0)
MessageBox( 0,"Couldn't init","error")
else
{
BASSMOD_MusicLoad(0,filename,0,0,4);
BASSMOD_MusicSetPosition(pattern);
BASSMOD_SetVolume(vol);
BASSMOD_MusicPlay();
}
}
}
return true;
}

//the volume scrollbar
dlg::OnVScroll(int nCommand,int nPos,int nID),int
{
CScrollBar *pScroll = GetControl(nID);
SELECT nCommand
{
CASE SBTHUMBTRACK:
vol = nPos;
pScroll->SetScrollPos(vol);
vol = 100 - vol;
BASSMOD_SetVolume(vol);
CASE SBLINEUP:
vol = pScroll->GetScrollPos()-1;
if(vol < 0) vol = 0;
vol = 100 - vol;
pScroll->SetScrollPos(100-vol);
BASSMOD_SetVolume(vol);
CASE SBLINEDOWN:
vol = pScroll->GetScrollPos()+1;
if(vol > 100) vol = 100;
vol = 100 - vol;
pScroll->SetScrollPos(100-vol);
BASSMOD_SetVolume(vol);
CASE SBPAGEUP:
vol = pScroll->GetScrollPos()-10;
if(vol < 0) vol = 0;
vol = 100 - vol;
pScroll->SetScrollPos(100-vol);
BASSMOD_SetVolume(vol);
CASE SBPAGEDOWN:
vol = pScroll->GetScrollPos()+10;
if(vol > 100) vol = 100;
vol = 100 - vol;
pScroll->SetScrollPos(100-vol);
BASSMOD_SetVolume(vol);
}
return true;
}

//the Position scrollbar
dlg::OnHScroll(int nCommand,int nPos,int nID),int
{
CScrollBar *pScroll = GetControl(nID);
CStatic *pStatic = GetControl(STATIC_PATTERN);
StopTimer();
SELECT nCommand
{
CASE SBTHUMBTRACK:
pattern = nPos;
pScroll->SetScrollPos(pattern);
pStatic->SetText(ltrim$(str$(pattern,0))+"  ");
pattern = pattern & 0xFFFF;
BASSMOD_MusicSetPosition(pattern);
CASE SBLINELEFT:
pattern = pScroll->GetScrollPos() - 1;
if(pattern < 0) pattern = 0;
pScroll->SetScrollPos(pattern);
pStatic->SetText(ltrim$(str$(pattern,0))+"  ");
pattern = pattern & 0xFFFF;
BASSMOD_MusicSetPosition(pattern);
CASE SBLINERIGHT:
pattern = pScroll->GetScrollPos() + 1;
if(pattern > BASSMOD_MusicGetLength(0)) pattern = BASSMOD_MusicGetLength(0);
pScroll->SetScrollPos(pattern);
pStatic->SetText(ltrim$(str$(pattern,0))+"  ");
pattern = pattern & 0xFFFF;
BASSMOD_MusicSetPosition(pattern);
CASE SBPAGELEFT:
pattern = pScroll->GetScrollPos() - 10;
if(pattern < 0) pattern = 0;
pScroll->SetScrollPos(pattern);
pStatic->SetText(ltrim$(str$(pattern,0))+"  ");
pattern = pattern & 0xFFFF;
BASSMOD_MusicSetPosition(pattern);
CASE SBPAGERIGHT:
pattern =pScroll->GetScrollPos() + 10;
if(pattern > BASSMOD_MusicGetLength(0)) pattern = BASSMOD_MusicGetLength(0);
pScroll->SetScrollPos(pattern);
pStatic->SetText(ltrim$(str$(pattern,0))+"  ");
pattern = pattern & 0xFFFF;
BASSMOD_MusicSetPosition(pattern);
}
StartTimer(100);
return true;
}


dlg::OnMenuPick(int nID),int
{
CScrollBar *pScroll;
CStatic *pStatic;
CEdit *pEdit;
select nID
{
case 1:
CloseDialog(1);
case 2:
BASSMOD_Free();
if(BASSMOD_Init(-1,freq,16)=0)
MessageBox( 0,"Couldn't init","error");

filename = FileRequest("Load MOD file",this,1,filter);
if(BASSMOD_MusicLoad(0,filename,0,0,4)=0)
MESSAGEBOX( 0,"Couldn't load file","Error")
else
{
pEdit = GetControl(EDIT_NAME);pEdit->SetText(BASSMOD_MusicGetName());
pScroll = GetControl(POSITION_SCROLL);pScroll->SetScrollRange(0,BASSMOD_MusicGetLength(0));
pStatic = GetControl(STATIC_PATTERN);pStatic->SetText("0  ");
pStatic = GetControl(STATIC_POSITION);pStatic->SetText("0  ");
pScroll->SetScrollPos(0);
}

}
return true;
}

dlg::OnTimer(int nIDEvent),int
{
CStatic *pStatic;
CScrollBar *pScroll;
IF(BASSMOD_MusicIsActive())
{
pos = BASSMOD_MusicGetPosition();
pattern = pos & 0xffff;
pos = pos / 0xffff;
pStatic = GetControl(STATIC_PATTERN);pStatic->SetText(ltrim$(str$(pattern,0))+"  ");
pStatic = GetControl(STATIC_POSITION);pStatic->SetText(ltrim$(str$(pos,0))+"  ");
pscroll = GetControl(POSITION_SCROLL);pScroll->SetScrollPos(pattern);
}
return true;
}


EDIT: Code updated to reflect latest compiler changes
Title: Re: MOD player
Post by: Ionic Wind Support Team on January 02, 2006, 02:27:05 PM
A couple of more mods for the player.

Rainynit.mod (Rainynight) was one of the first MOD songs I ever heard on the Amiga.   And probably what got me hooked on the format for a while.

Title: Re: MOD player
Post by: Ionic Wind Support Team on January 02, 2006, 03:00:52 PM
A site with a large archive of old mods.

http://www.artificiallives.com/mods/modarch/mods/

A lot of these were from games, or graphics demos.  Some won't play in modplayer...but most will.
Title: Re: MOD player
Post by: Steven Picard on January 02, 2006, 04:46:12 PM
I remember the MODs on the AMIGA!   I loved them.  The Amiga is my all time favorite computer.  I owned an A500, A1200 and a CDTV.  *Sigh*  The good old days...
Title: Re: MOD player
Post by: Zen on January 02, 2006, 05:11:00 PM
Ive never heard of these types of audio formats. Maybe because i didnt have an amiga. They seem a lot like Midi files though. Prety cool demo. Aurora's programs are becoming more advanced every day.

Lewis
Title: Re: MOD player
Post by: Ionic Wind Support Team on January 02, 2006, 05:36:38 PM
The MOD (tracker) format contains music laid out in 'patterns' each pattern has 64 rows.  Every instrument in the mod is actually a distinct and separate sound sample.

Originally showing up in demos and games it became a popular format for the techno geek to write music in.  The original format was limited to 3 1/2 octives if I remember correctly.  And being a geek way of making music the original editors had you enter notes in hex format ;)

It was a good format for games since you could repeat any pattern over and over again without using much disk space. 
Title: Re: MOD player
Post by: Ionic Wind Support Team on January 02, 2006, 05:43:09 PM
http://en.wikipedia.org/wiki/Fast_Tracker
Title: Re: MOD player
Post by: Zen on January 02, 2006, 05:59:20 PM
Wow that is super geeky. Making music in HEX. I can see how it was cool a few years ago.

Lewis
Title: Re: MOD player
Post by: Ionic Wind Support Team on January 02, 2006, 06:01:58 PM
It did improve though.  And there were dozens of 'tracker' programs available for making music, including one I wrote called ScoreTracker. 

The format lost its popularity once the Amiga died and disk/memory space was no longer an issue.  Still a very big cult following.
Title: Re: MOD player
Post by: Zen on January 02, 2006, 06:30:43 PM
Its nice to see that old things are not always forgotten.

Lewis
Title: Re: MOD player
Post by: Steven Picard on January 02, 2006, 07:07:25 PM
Paul, I remember one MOD tracker program (a famous one - it's been quite awhile so I don't remember its name) that could play in 8 voices simultanously (eventually even 16 but it sounded very tinny.)  What was it?  OctaMod or something.  Amiga was designed to only play 4 voices.

Also, since we're talking about Amiga, remember HAM (Hold and Modify Mode)? 4096 colors on screen at the same time.  I remember bragging about that to my PC (and ST) using friends.
Title: Re: MOD player
Post by: Zen on January 02, 2006, 07:19:57 PM
Bit before my time but i do wish i could have seen the big changes in the IT industry. Its not so "Crazy" no as it used to. I had a sega mastersystem though, and looking back at the graphics on that. Its come along way since then. Just take a look at Half-Life 2.

Lewis
Title: Re: MOD player
Post by: Parker on January 02, 2006, 07:34:25 PM
I wish I was around to see all of that, but you know, someday I'll probably be talking about "Remember when we had to use Windows XP?" and how we were using only 32-bit processors, 32 bit graphics, etc. :)

I've never looked at the modplayer demo really, but it's pretty cool now that I take the time.
Title: Re: MOD player
Post by: Zen on January 03, 2006, 06:17:30 AM
Well im already on the 64-Bit processor with my main machine, still 32 on the laptop. But it will be cool in about 30 years time or something when we have 10gig processors.

I remember my first PC was a 486 and it had 120mb disk space. Not sure about anything else as i didnt know anything about computers back then. Theres not a lot you can do with 120mb now. How times change.

Lewis
Title: Re: MOD player
Post by: Parker on January 03, 2006, 08:24:12 AM
One of my friends has a 64 bit processor, he got it so he could have a fast gaming computer, but 32 bit games won't run all that fast on those, they have to use a kind of 32 bit emulation. I suppose it's pretty fast if he can find a 64 bit game though.
Title: Re: MOD player
Post by: ThadMiller on January 03, 2006, 09:45:12 AM
Wow!  MOD files... I haven't seen them since... well, since I put my Amiga away.  I remember back in the day one of the local BBS SysOps decided to have a "get together", so I took my A500 to show off.  Everyone was bragging about their MIDI collections, then I hooked up my system and played this MOD http://www.modarchive.com/cgi-bin/download.cgi/R/rhy.mod - needless to say, all the PC users were impressed.  Ahh the memories.
Title: Re: MOD player
Post by: Ionic Wind Support Team on January 03, 2006, 02:29:38 PM
Some of the MOD's still amaze me.   If you run accross GuitarSlinger.mod give it a listen ;)
Title: Re: MOD player
Post by: redea30591 on April 09, 2006, 03:46:24 AM
Quote from: stevenp on January 02, 2006, 07:07:25 PM
Paul, I remember one MOD tracker program (a famous one - it's been quite awhile so I don't remember its name) that could play in 8 voices simultanously (eventually even 16 but it sounded very tinny.)  What was it?  OctaMod or something.  Amiga was designed to only play 4 voices.

Also, since we're talking about Amiga, remember HAM (Hold and Modify Mode)? 4096 colors on screen at the same time.  I remember bragging about that to my PC (and ST) using friends.

Craz6, but I used to have a .MOD->.MID convertor, and would copy one instrument over to another name several times just to create a bunch of "fake" instrument names in the .mod file (temporary purposes), then compose the music on the .mod editor, convert the file to .mid and play it in Windows Media Player out to my keyboard....  Fact was I didn't care what the .mod file sounded like on the PC, I just cared what the .mid sounded like after conversion (and .mid files lost the instrument samples, so ....)    This was when the only music editors I could find used CAkewalk's "Piano Roll" format editing, or  WinJammer's Event Editor format (where you create an event to turn the note on at xxx:xxx:xx.xx  and tell it that it'll last for xxx:xx.xx, then turn the note off later on, etc...  Neither was really my cup of tea, and the DOS based MODEDIT seemed more powerfull , and Free.... My favorite two ways!  So I used the MODEDITOR as a MIDIEditor with a middleman (mod2midi) ....
Title: Re: MOD player
Post by: kryton9 on August 25, 2006, 11:32:10 PM
The exe runs fine, but when I went to compile it from the source, it couldn't find the lib file?
Title: Re: MOD player
Post by: Ionic Wind Support Team on August 26, 2006, 01:11:20 AM
Tools->Create Import Library.

Same as using any other DLL.