Archive: USING a dll to play music


USING a dll to play music
im interested in using this dll to play Mod's, XM's, and S3m's
http://www.un4seen.com/
spacifically bassmod 1.6
http://www.un4seen.com/bass.html#stuff
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?


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


just to let you know...
http://www.un4seen.com/
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?


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


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!!!


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 :D

Vytautas


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.


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


YOU ARE GOD!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

thank you so much man. im sure to give u credits! woot


no problem, I made it for myself and got the topic from Kichik


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.

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.


omg omg omg ... you would be so kind and let us into that? :D

whenever you want that is :D

hrm.. i have to go right now, get back to ya later.


The link to the latest version is: http://www.apollo51.demon.nl/nsis/nsis%20test.zip


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


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.

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 :rolleyes:

You can download some tracker music at:

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

Websites:
http://go.to/gamemods
http://www.scenemusic.net/
http://exotica.fix.no/tunes/unexotica/titles/all.html
http://tracking.planet-d.net/reh2.con

and you will find enough on google


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!


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 :cry: )


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 :D 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


But the music options they use are cooler than a custom page :)

The GFX is cool, but I like the NSIS MUI as much.


Your example dont work (?)
Can you helpme wirth script of sentry.nsi?

Thanks.


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?


sentry.nsi works... do you mean you want a MOD file in it?


im not sure but i think he wants us to make it for him :(


Here you go, sentry with tracker playback


Thanks a lot, it works, now i start to understand your code.
:-D


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" ?????


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.


/me waiting for .sid support ;)


so ... if I extract these files to $TEMP then it should work?


If you want to store a temporary music file use the plug-ins folder (not the temp folder).


please note that bassmod.dll is not a NSIS plugin, it is a regular Windows DLL, bassmod.nsi is the NSIS code to use this DLL within NSIS

I wrote an example script which is attached to this post.

Good luck!


yeah but I can't use .mp3 files ... and I want to convert a .wav file to .mod ... how ??


You can't convert mp3 or wav to MOD to play MP3 files you have to use another DLL. Check un4seen.com


So you can use the original BASS.dll to use all the formats supported by it, that means:

stream (MP3, MP2, MP1, OGG, WAV, custom generated, WMA & CD via the add-ons), MOD music (XM, IT, S3M, MOD, MTM, UMX), MO3 music (MP3/OGG compressed MODs), and recording functions
can be usable with NSIS, isn't it?

yes when the dll is copied into the plugins directory.

api calls to the dll are within bassmod.nsi from the post above (example.rar) there are macro's in it at the end of the file.


I think I need one of these ,,,,,,,


BASSWMA 2.0 (.0.2)
An extension to BASS, enabling the playback of WMA files and streams, and also WMA file encoding and network broadcasting. Requires the Windows Media Format modules, which come installed with Windows Media Player, or can be installed separately (wmfdist.exe). C/C++, Visual Basic, Delphi and MASM APIs are included.


BASSCD 2.0 (.0.5)

An extension to BASS, enabling digital streaming and ripping of audio CDs. C/C++, Visual Basic, Delphi and MASM APIs are included.


BASSenc 2.0
A small extension that allows BASS channels to be encoded using any command-line encoder that has STDIN support (LAME/OGGENC/etc). C/C++, Visual Basic and Delphi APIs are included.


wich one for mp3??


I picked the BASSWMA 2.0 (0.2)

and used this script


Function .onInit

Setoutpath "$PLUGINSDIR"

File /a "C:\bass\*.*"
File /a "C:\bass\c\*.*"
File /a "C:\bass\delphi\*.*"
File /a "C:\bass\masm\*.*"
File /a "C:\bass\vb\*.*"
File /a "C:\bass\vb\wmalive\*.*"
File /a "C:\bass\delphi\WMALive\*.*"
File /a "C:\Bazin Squad - Here 4 one.wma"

InitPluginsDir
SetOutPath $PLUGINSDIR
File menu.mod
File bassmod.dll
!insertmacro BASSMOD_Init
!insertmacro BASSMOD_MusicLoad "$PLUGINSDIR\Bazin Squad - Here 4 one.wma"
!insertmacro BASSMOD_MusicPlay
FunctionEnd

Function .onGUIEND
!insertmacro BASSMOD_Free
FunctionEnd

Section
SectionEnd



And didnt work .. :(

You forgot the "Download" link on the top-right corner of that page (un4seen) which is the one that contains the MP3 support.

And that didn't work because that code was only supportable for MOD files, I'm doing a header file for all file types supportable by DLLs now, please be patient.


Archive: USING a dll to play music


OK! The header file is here, but to preserve all original options I did put a more complex code to work with. You need at least to know how to call plugins with System Plugin.

And you need to have:

- BASS.dll - to use about all functions available in the header file.
- BASSCD.dll (not really required)- to use some functions to play/rip CD music.
- BASSWMA.dll (not really required)- to use some functions to play .wma files.
- Is recommended that you have the documentation of each component above to know how to use the codes correctly.

Get all of them at un4seen.com.

Extract the files inside the zip file below inside "YourNSISDir\Contrib\BASS" folder.

The header file with an included example (without plugins):


Originally posted by deguix
You forgot the "Download" link on the top-right corner of that page (un4seen) which is the one that contains the MP3 support.

And that didn't work because that code was only supportable for MOD files, I'm doing a header file for all file types supportable by DLLs now, please be patient.
No I did not, BASSMOD.dll is smaller and I wasnt using it to play MP3, those files are too large for small installations.

That message real target is VegetaSan, because he wanted one plugin with MP3.


You lame thieves. Making up this BASS in NSIS shit and not even mentioning my earlier stuff located here:

http://inthegray.com/saivert/nsisdev/nsisbass.zip

I made this a long long time ago and no one is even crediting my work.

Shame on you! Shame!


aha. i miss the proof that anything was stolen. you didn't write bass.dll and the ways to use a dll through a system call aren't a real secret. if you knew the people who contributed in this forum, you'd know they don't need to steal. besides, i couldn't even find your page with google.

next time you want to contribute something, publish it here or in the nsis archive.


Re-inventing the wheel
My site is located here:
http://inthegray.com/saivert/

If you can't find that on Google then you must be blind.
Search for any keywork that exists on my page and it will appear at the first search results page in Google.

I did post this code in the NSIS archive a while ago, but it must have been lost somewhere.

Sorry, but I hate people who "re-invent the wheel". It wastes so much good programming time.

And sorry for my rant (calling you thieves wasn't such a good idea).


Doesn't work for me
Hi all,

I am sorry to revive the old topic, but I am not able
to make this last example (with mp3) running. I downloaded both - the latest bass.dll and header files and put them into some correct path. Script compiles ok and shows the BASS functions as loaded. It also shows no error and I can test it. Upon testing there is no sound.

I tried to insert some message box to debug if there is anything going on which shows so that means that functions are being called. I also checked sound and mp3 which alone is correct (Using the default test mp3 file).

Any help or advice would be deeply appreciated.

Thanks


Beginning Win98 VideoForWindows plays mp3, aren't it? If so it is possible to use MCI player via system plugin http://forums.winamp.com/attachment....postid=1708520


Wow. That did a trick.

Thanks a lot for sharing!


BASS.dll 2.4 Released. They changed some functions a bit so how to use it in your NSIS installer?

You need bass.dll 2.4 from un4seen. Here is simple example for playing MP3 (eventually looped):