Skip to content
⌘ NSIS Forum Archive

USING a dll to play music

60 posts

MindlessOath#

USING a dll to play music

im interested in using this dll to play Mod's, XM's, and S3m's
These pages are dedicated to bringing you some fine audio related software, with the focus on quality and efficiency. Including the XMPlay audio player, the BASS audio library and the MO3 audio format!

spacifically bassmod 1.6

it uses a dll called BASSMOD.dll

how do i go about loading that dll up and calling it to play my music in the NSIS install? i just want it to start the music and loop until closed the application.

im not really a great programmer with all this stuff. i did a search and all it came up with is playing music with bgimage or whatever... and that was only for WAV files 🙁
can anyone help me out? i posted a topic at the forums at the other location, but im sure i need more help from your guys end of things.

im sure i can find out what functions need to be called when needed, but how would i integreat that into NSIS script?
Vytautas#
I am currently working on a NSIS plugin for playing OGG files and possibly later MP3s. I have not come across the formats you listed before therefore I'm not certain of how this dll works but a starting point would be to get the list of exported funtions and their c prototypes so that they can be called using the system plugin.

Vytautas
MindlessOath#
just to let you know...
These pages are dedicated to bringing you some fine audio related software, with the focus on quality and efficiency. Including the XMPlay audio player, the BASS audio library and the MO3 audio format!

has a dll that will play mp3's ogg's and etc.. aswell.. they have source code for it i belive in vb, c++, and probably delphi.

hope that helps you out.

ok.. so once i know these functions.. how do i implement them into the NSIS scrip??? im a total noob at NSIS right at the moment.. i know only basic functions and whatever is in the help file.

anyone know how i go about implimenting these functions and such from a dll to play music?
Yathosho#
hehe, mp3s/oggs are kinda against the nature of lean installers (that applies to downloadable files of course). but tracker formats would definitely be cool 🙂

however, i'd be interested to know, if your dll (Vytautas) can play the files looped (gapless?).
MindlessOath#
ya thats what i was thinking.. why use mp3, wav, ogg, or other HUGE music files??? unless you install is huge already than a 3MB file added wont make much of a differnce, but using tracker music would be great... like mod's and XM's etc. www.modcentral.com i belive will clue you in on some of the music their. or is it www.modplug.com - ya thats it.

they are idea cause they are only kilobytes in size, and their for dont take up much at all space, problem is, not many applications or programmers know how to impliment tracker playing in applications. but some do, and thats where we get these dll's etc. hopefully someone could impliment this trackers support. i have seen one installer that provides support using this.... but i dont like it as much as NSIS, to much bloat if ya ask me.

i just went searching through the archive.. and it looks like IM not going to be able to program this function into my scripts at all.. so if someone could do this for me (and many many others) it would be greatly appreciated!!!
Vytautas#
Can you convert wav file to mod files?

You see the main reason for the plugin was also the ability to compress wave file into ogg format for distribution and the decode them during setup. As a added functionality, since the decoding engine is already in the plugin I will add the ability to play the files aswell.

Looped play is in the todo list, very close to the top of it actually. Will most likely be in the first release.

Also thanks for the link I will check out their code and see if I can improve on mine 😁

Vytautas
MindlessOath#
well all i ask is when trying to improve on your script... try and add the MOD play support if at all possible.

i do belive Mod's can be converted into any format.. usually mp3, probably wav and most likely if it can go in either or of those two.. it can get into ogg format.

a MOD is basically a buncha really small wav file samlples played in a list that tunes the tones up and down to make music. its very advanced, and its REAL MUSIC since you HAVE to compose it. thats what makes it so unique. and thats what makes it so small too.
apollo51#
Here are the functions I made to play MOD files using BASSMOD.dll (version 1.6):
$filename is the file to load
$songtitle is the song title (doh)

attachment: example with multiple mod files in a dropdown list

if any1 knows how to put play/stop buttons within the bottom of the MUI, please PM/Mail me!! (i want to skip the MOD page)

oh yeah, the defines for BASS_MUSIC_LOOP etc are in the example...
-------------------------------------------------------------------------------

Function BASSMOD_MusicGetName
System::Call /NOUNLOAD 'BASSMOD::BASSMOD_MusicGetName()t.r0'
StrCpy $songtitle $0
FunctionEnd

Function BASSMOD_Init
System::Call /NOUNLOAD 'BASSMOD::BASSMOD_Init(i,i,i) (-1,44100,0)'
FunctionEnd

Function BASSMOD_MusicStop
System::Call /NOUNLOAD 'BASSMOD::BASSMOD_MusicStop'
FunctionEnd

Function BASSMOD_MusicLoad
System::Call /NOUNLOAD 'BASSMOD::BASSMOD_MusicLoad(i,t,i,i,i) (0,"$PLUGINSDIR\$filename",0,0,${BASS_MUSIC_LOOP}|${BASS_MUSIC_RAMPS}|${BASS_MUSIC_SURROUND}|${BASS_MUSIC_POSRESET})'
FunctionEnd

Function BASSMOD_Rewind
System::Call /NOUNLOAD 'BASSMOD::BASSMOD_MusicSetPosition(i) (0)'
FunctionEnd

Function BASSMOD_MusicFree
System::Call /NOUNLOAD 'BASSMOD::BASSMOD_MusicFree'
FunctionEnd

Function BASSMOD_Free
System::Call 'BASSMOD::BASSMOD_Free'
FunctionEnd

Function BASSMOD_MusicPlay
System::Call /NOUNLOAD 'BASSMOD::BASSMOD_MusicPlay'
FunctionEnd
MindlessOath#
YOU ARE GOD!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

thank you so much man. im sure to give u credits! woot
MindlessOath#
im just so really glad you decided to share with us. you are so kind, and i am very appreciative of the work you had done.

btw to let others know.. you have to have the dll basemod.dll in the directory.


also your bug report...
Function .onGUIEnd
Call BASSMOD_Free
;HelpButton::end
System::Free 0
FunctionEnd
as you can see i had to comment out ;HelpButton::end
dunoo why or what it does, but it compiled after i removed it.
apollo51#
hehe yes, I forgot to remove it, I was trying to add Play/Stop controls to the bottom of the MUI pages, but didn't work out.

I updated the code with XM/IT/MOD/S3M/MTM listing and functions for BASSMOD instead of System Calls

Don't know if the functions are in the test.nsi that I've uploaded here.
MindlessOath#
omg omg omg ... you would be so kind and let us into that? 😁

whenever you want that is 😁

hrm.. i have to go right now, get back to ya later.
Fl0ppy#
music installing

Great work!! but maybe you can helpme with this:

I want a installer with a .mod playing.

With the next sentences (l00k the attachment)

I mind, just a: play music while installing the files.

Thanks 😉
MindlessOath#
it does just play music when installing files. it has that too. you dont have to use all that stuff.
basically just remove the custom page stuff.

SetCompressor lzma ;7-Zip
SetCompress force
SetCompressorDictSize 8 ;for large installations use a higher, like 32, 8 is default
SetDateSave On
SetDataBlockOptimize On

Name "map name"
OutFile "test0001.exe"
;Icon 'F:\RavenShield.ico' ;use mui icon now

DirText 'Choose Directory to Install'
InstallDir 'Didnt find RavenShield on your system, please browse for a location'
InstallDirRegKey 'HKLM' 'SOFTWARE\Red Storm Entertainment\RAVENSHIELD' 'InstalledPath'

CRCCheck On
XPStyle on
SilentInstall Normal
ShowInstDetails Show
AutoCloseWindow false
BrandingText "RvS Map installer - by MindlessOath msu by:@p0ll0"
;BGGradient "FDF3DB" "EDAC3B"


;BASSMOD 1.6 (c) 1999-2002 Ian Luck.
;Please report bugs/suggestions/etc... to bassmod@un4seen.com
;See the BASSMOD.CHM file for more complete documentation

!define BASS_ACTIVE_STOPPED 0
!define BASS_ACTIVE_PLAYING 1
!define BASS_ACTIVE_STALLED 2
!define BASS_ACTIVE_PAUSED 3

;Error codes returned by BASSMOD_GetErrorCode()
!define BASS_OK 0 ;all is OK
!define BASS_ERROR_MEM 1 ;memory error
!define BASS_ERROR_FILEOPEN 2 ;can't open the file
!define BASS_ERROR_DRIVER 3 ;can't find a free sound driver
!define BASS_ERROR_HANDLE 5 ;invalid handle
!define BASS_ERROR_FORMAT 6 ;unsupported format
!define BASS_ERROR_POSITION 7 ;invalid playback position
!define BASS_ERROR_INIT 8 ;BASS_Init has not been successfully called
!define BASS_ERROR_ALREADY 14 ;already initialized
!define BASS_ERROR_ILLTYPE 19 ;an illegal type was specified
!define BASS_ERROR_ILLPARAM 20 ;an illegal parameter was specified
!define BASS_ERROR_DEVICE 23 ;illegal device number
!define BASS_ERROR_NOPLAY 24 ;not playing
!define BASS_ERROR_NOMUSIC 28 ;no MOD music has been loaded
!define BASS_ERROR_NOSYNC 30 ;synchronizers have been disabled
!define BASS_ERROR_UNKNOWN -1 ;some other mystery error

;Device setup flags
!define BASS_DEVICE_8BITS 1 ;use 8 bit resolution, else 16 bit
!define BASS_DEVICE_MONO 2 ;use mono, else stereo
!define BASS_DEVICE_NOSYNC 16 ;disable synchronizers
!define BASS_DEVICE_LEAVEVOL 32 ;leave the volume as it is

;Music flags
!define BASS_MUSIC_RAMP 1 ;normal ramping
!define BASS_MUSIC_RAMPS 2 ;sensitive ramping

;Ramping doesn't take a lot of extra processing and
;improves the sound quality by removing "clicks".
;Sensitive ramping will leave sharp attacked samples,
;unlike normal ramping.

!define BASS_MUSIC_LOOP 4 ;loop music
!define BASS_MUSIC_FT2MOD 16 ;play .MOD as FastTracker 2 does
!define BASS_MUSIC_PT1MOD 32 ;play .MOD as ProTracker 1 does
!define BASS_MUSIC_POSRESET 256 ;stop all notes when moving position
!define BASS_MUSIC_SURROUND 512 ;surround sound
!define BASS_MUSIC_SURROUND2 1024 ;surround sound (mode 2)
!define BASS_MUSIC_STOPBACK 2048 ;stop the music on a backwards jump effect
!define BASS_MUSIC_CALCLEN 8192 ;calculate playback length
!define BASS_MUSIC_NOSAMPLE 400000 ;don't load the samples

;Sync types (with!define BASS_ChannelSetSync() "param" and
;SYNCPROC "data" definitions) & flags.

!define BASS_SYNC_POS 0
!define BASS_SYNC_MUSICPOS 0
!define BASS_SYNC_MUSICINST 1
!define BASS_SYNC_END 2
!define BASS_SYNC_MUSICFX 3
!define BASS_SYNC_ONETIME $80000000 ;FLAG: sync only once, else continuously

!include "MUI.nsh"

!define MUI_HEADERIMAGE
!define MUI_ICON "RavenShield.ico"
!define MUI_HEADERIMAGE_BITMAP "rvs-orange-header-optimized.bmp"
!define MUI_WELCOMEFINISHPAGE_BITMAP "orange-wizard.bmp"
;!define MUI_COMPONENTSPAGE_SMALLDESC

!insertmacro MUI_PAGE_WELCOME
;Page custom ShowCustom LeaveCustom
!insertmacro MUI_PAGE_LICENSE "C:\Documents and Settings\Mindless\My Documents\PIMP\sewer.txt"
!insertmacro MUI_PAGE_DIRECTORY
;!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_LANGUAGE "English"
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS

!define MUI_FINISHPAGE_LINK "C:\Documents and Settings\Mindless\My Documents\nsis_mod_test\pimpgui2.nsi"
!define MUI_FINISHPAGE_LINK_LOCATION http://www.tacticalcenter.net
;!define MUI_FINISHPAGE_LINK_COLOR ""

/*
Var hwnd
Var playing
*/

Var filename
Var songtitle


;=====================================================================
;BEGIN Code
;=====================================================================

Function .onInit
InitPluginsDir
SetOutPath $PLUGINSDIR

File "bassmod.dll"

;XM/IT/MOD/S3M/MTM

File /nonfatal "music\*.xm"
File /nonfatal "music\*.it"
File /nonfatal "music\*.mod"
File /nonfatal "music\*.s3m"
File /nonfatal "music\*.mtm"

Push "*.xm"
Call ListFiles
Push "*.it"
Call ListFiles
Push "*.mod"
Call ListFiles
Push "*.s3m"
Call ListFiles
Push "*.mtm"
Call ListFiles


Call BASSMOD_Init
Call BASSMOD_MusicLoad
Call BASSMOD_MusicGetName
Call BASSMOD_MusicPlay
FunctionEnd

Function .onGUIEnd
Call BASSMOD_Free
System::Free 0
FunctionEnd

;=====================================================================
;Install Section
;=====================================================================

Section
Sleep 1000
SectionEnd

;=====================================================================
;END Code
;=====================================================================

;=====================================================================
;BEGIN MOD file functions
;=====================================================================

Function BASSMOD_MusicGetName
System::Call /NOUNLOAD 'BASSMOD::BASSMOD_MusicGetName()t.r0'
StrCpy $songtitle $0
FunctionEnd

Function BASSMOD_Init
System::Call /NOUNLOAD 'BASSMOD::BASSMOD_Init(i,i,i) (-1,44100,0)'
FunctionEnd

Function BASSMOD_MusicLoad
System::Call /NOUNLOAD 'BASSMOD::BASSMOD_MusicLoad(i,t,i,i,i) (0,"$PLUGINSDIR\$filename",0,0,${BASS_MUSIC_LOOP}|${BASS_MUSIC_RAMPS}|${BASS_MUSIC_SURROUND}|${BASS_MUSIC_POSRESET})'
FunctionEnd

Function BASSMOD_Free
System::Call 'BASSMOD::BASSMOD_Free'
FunctionEnd

Function BASSMOD_MusicPlay
System::Call /NOUNLOAD 'BASSMOD::BASSMOD_MusicPlay'
FunctionEnd

;=====================================================================
;END MOD file functions
;=====================================================================

;=====================================================================
;BEGIN misc functions
;=====================================================================

Function ListFiles
Pop $3
FindFirst $0 $1 "$PLUGINSDIR\$3"
StrCmp $0 "" skipSound
StrCpy $filename $1
moreSounds:
StrCmp $1 "" noMoreSounds
StrCpy $9 "$9|$1"
FindNext $0 $1
Goto moreSounds
noMoreSounds:
FindClose $0
skipSound:
FunctionEnd

;=====================================================================
;END misc functions
;=====================================================================
and thats all you really need, you could slim it down even more than that.
apollo51#
If you just want to play 1 mod file, you can skip much code for example the file *.mod etc, listing the music, the custom page and the function listfiles.
And not all definitions are needed, only the ones used.

the only thing I want to do is make a checkbox loop or randomize playlist, but the second option will be difficult because bassmod doesn't support playlists.

This is my second day on the forum, and I never thought that people actually would be using my code 🙄

You can download some tracker music at:

Shoutcast: http://nectarine.hrxnet.de:8002/listen.pls

Websites:





and you will find enough on google
MindlessOath#
for being very new, you are awesome! hrm.. playlists.. you can probably do that function, just need some additional coding in nsis i think, im still new to the coding nsis way tho.

i dont see why you would want to put buttons and such for the music. i think all that is neccisary is a volume bar, mabe a stop/start button, hrm.. selection of files is pritty awesome, but i would only include that fucnction with large install files, like big games, or large distrabutions. :P

listening to mods right now, i love the sounds, music to my ears, none of that radio BS i hear now adays. "F MTV" MODS RULE!
apollo51#
I basicly wanted to do something like the ware guys from MYTH like: http://www.apollo51.demon.nl/nsis/Wo...aller.MYTH.zip

this one will probably be a Delphi/C application that unpacks the bassmod.dll as RCDATA and plays the mod files from memory as RCDATA (compiled within the exe)

I did it too in Delphi, but I like NSIS much more!

Yes, tracker music is cool, it reminders me of the old games like Xenon 2, Lotus, Zool and Zone 66 (Cant find a MOD of that game 😢 )
MindlessOath#
ya thats what i was thinking about too... but not in the same light :P
their installers are really cool, as well as some other elite installers that have all custom/movable grfx/ascii and etc. some of these people are extreamly intelegent.

wow thats a nice ass installer, man that looks awesome, and sounds awesome too. it plays a few songs aswell. man, how do i get one of those 😁 custom direct3d/opengL or something, plus the random mods.. life doesnt get that goood. damn you c++ guys that know everything, i only know simple stuff count >> lalaalalaalaala
apollo51#
But the music options they use are cooler than a custom page 🙂

The GFX is cool, but I like the NSIS MUI as much.
MindlessOath#
man, im a noob and i know how to get it to work. Fl0ppy can u display the msg that is comming up as the error?

whats not working? are u using the correct version of nsis.

do you have the DLL file, do u have a mod?
apollo51#
Here you go, sentry with tracker playback
VegetaSan#
But where should I place these files

- sentry.nsi
* I have : C:\Program Files\NSIS\Include\sentry.nsi

- BASSMOD.dll
* I have : C:\Program Files\NSIS\Plugins\BASSMOD.dll

- and 64ish.xm
* dont know where !

please help me > are these files in the correct places?

And how should I use them ?

!include "sentry.nsh" ?????
Joost Verburg#
Temporary files can be stored in the plug-ins folder after using InitPluginsDir.

If you can't get it to work please attach relevant script code and a detailed problem description.