mmod - mini console mod player

Developed or developing a new product in PureBasic? Tell the world about it.
rudz
User
User
Posts: 35
Joined: Sun Mar 21, 2010 6:59 am
Location: Denmark
Contact:

mmod - mini console mod player

Post by rudz »

This is a tiny console app i whipped together in a few minutes, because i wanted a quick method to play tracker modules without any hassle.
It uses the build-in tracker stuff in PB, which works nicely.

Pressing ESC quits program.
Auto loops song if position hits 255 (which should be the end).

Compiles in Windows and Linux.
If compiled in Linux, note that it requires pb 4.50 (and the SDL audio lib as well).

Make a shortcut (desktop/quicklaunch for windows) and panel for linux to drop modules on it (or use regular cmd parameter).

Code: Select all

 InitSound() ; this is vital :)
  Define sMod.s=ProgramParameter(0) ; get module name
  Define iMod.i=LoadModule(#PB_Any,sMod) ; load module
  ; set up the lenght of the lines depending on system
  If IsModule(iMod)
    OpenConsole()
    ClearConsole()
    EnableGraphicalConsole(1)
    Define title.s="minimod v0.0.1 - by rudz"
    CompilerSelect #PB_Compiler_OS
  CompilerCase #PB_OS_Windows
    title+" [win]"
    Define line.i=80
    ConsoleTitle(title)
  CompilerCase #PB_OS_Linux
    title+" [lin]"
    Define line.i=79
  CompilerEndSelect
    PrintN(title)
    PrintN(LSet("-",line,"-"))
    PrintN("module: "+sMod)
    PrintN("row :"+Space(7)+"pos:")
    PrintN(LSet("-",line,"-"))
    ModuleVolume(iMod,80) ; set mod volume to 80
    PlayModule(iMod) ; begin play
  EndIf
  Define inK.s,row.s,pos.s
  Repeat
    Delay(1) ; ~1 ms delay
    ConsoleLocate(7,4) ; jump to ROW output location
    row=LSet(Str(GetModuleRow(iMod)),4," ") ; pad the row
    Print(row)
    ConsoleLocate(19,4) ; jump to POS output location
    pos=LSet(Str(GetModulePosition(iMod)),4," ") ; pad the pos
    Print(pos)
    ConsoleLocate(1,6)
    inK=Inkey()
    If GetModulePosition(iMod)=255 ; re-start tune
      SetModulePosition(iMod,0)
    EndIf
  Until inK=Chr(27)
EndIf
If IsModule(iMod) ; clean up
  StopModule(iMod)
  FreeModule(iMod)
  CloseConsole()
EndIf
End
AMD FX-8350 @ ~4.8GHz | 8GB Corsair DDR3-SDRAM @ 1800Mhz | 7even Ult & Manjaro 0.8.7.1 | PB 5.3
Web: rudz.dk