NSISBASS

Introduction

NSISBASS is a frontend to the BASS Sound System which allows you to play MPEG (all layers), OGG, MOD (all types) in your NSIS installers. It consists of a NSIS Header file (.NSH) wich defines several macros to do the actual work.

BASS is included in this package which is version 2.3 of the system. You can download a more recent version and replace the BASS.DLL file included. This should work perfectly fine except if the structure of the new version is different. Send me an e-mail if you got problems with the updated BASS.DLL.

This has only been tested with NSIS v2.35

Macros

nsisbass.nsh defines twelve (12) macros:


How to use

Initialization

The first thing you have to do to use this frontend is to insert a macro. You will only need to do this once if you only intend to play one single music file througout the entire installation. If you wish to play more than one, you have to extract the additional song files using the File script instruction.

; We need to include nsisbass.nsh to get the macros
!include "${NSISDIR}\contrib\nsisbass\nsisbass.nsh"

Function .onInit
  ; Insert the NSISBASS_INIT macro
  ${NSISBASS_Init}

  ; We can extract a song file as well (so you got something to play).
  File "/oname=$PLUGINSDIR\tempsong.mp3" "medley.mp3"
FunctionEnd

Playback of MPEG audio, OGG Vorbis and WAV

Using the NSISBASS_PLAY macro you can play the following types of media:

  • MPEG Audio (Layer I, Layer II & Layer III) version 1.0, 2.0 and 2.5
  • OGG Vorbis audio streams
  • WAVE packaged audio (WAV). Uses ACM to support virtually any codec.

  ; Start playing some music
  ${NSISBASS_Play} "medley.mp3" 0 ${BASS_SAMPLE_LOOP}

Playback of music modules (tracker based)

Using the NSIsBASS_PLAYMUSIC you can play the following types of media:

  • Protracker (MOD)
  • ScreamTracker v2 & v3 (STM, S3M)
  • FastTracker (XM)
  • ImpulseTracker (IT)
  • MO3 modules (samples compressed to MP3)
  • And lots more... (try it)

  ${NSISBASS_PlayMusic} "tune.xm" 0 ${BASS_SAMPLE_LOOP}

Playback of a file or stream on the internet

Using the NSISBASS_PLAYNET macro you can stream data from HTTP and FTP servers:

  • Shoutcast, Icecast & Icecast2
  • Proxy server support
  • Adjustable buffering
  • NSISBASS callback processing of download stream not implemented (no playlists yet)

  ; Start playing some music
  ${NSISBASS_PlayNet} "http://radioparadise.steadyhost.com:8032" 0 0 0 0

Retrieves tags/headers from a channel.

The NSISBASS_GETTAGS macro you can retrieve tags/headers for:

  • mp3 ID3v1 and ID3v2 tags
  • ogg comments
  • HTTP/ICY headers
  • Shoutcast metadata
  • RIFF/WAVE INFO tags
  • MOD music title, message, instruments and samples
  • ogg,RIFF/WAVE and MOD formats still need testing

  ; Get Shoutcast metadata from a channel
  ${NSISBASS_GetTags} ${BASS_TAG_META}

Pause output

The NSISBASS_PAUSE macro stops the output, pausing all musics/samples/streams.:

  ${NSISBASS_Pause}
  ${NSISBASS_IsPaused}
  Pop $0 ;$0 = 1

Resume output

The NSISBASS_RESUME macro resumes the output, using ChannelPlay.:

  ${NSISBASS_Resume}

Get master volume

The NSISBASS_GETVOLUME macro retrieves the current master volume level.:

  ${NSISBASS_GetVolume}
  DetailPrint "BASS Volume: $0%"

Set master volume

The NSISBASS_SETVOLUME macro sets the output master volume.:

  ${NSISBASS_SetVolume} 100

CPU usage

The NSISBASS_GETCPU macro retrieves the current CPU usage of BASS.:

  ${NSISBASS_GetCPU}
  DetailPrint "BASS CPU usage: $0%"

Channel Flags

The NSISBASS_SETCHANFLAGS macro sets the flags of a channel.:

  ${NSISBASS_SetChanFlags} ${BASS_SAMPLE_LOOP}

Error Code

The NSISBASS_ERRORGETCODE macro retrieves the error code for the most recent BASS function call in the current thread.:

  ${NSISBASS_ErrorGetCode}
  MessageBox MB_OK "BASS Error: $0"

Destruction

The NSISBASS_FREE stops playback and frees bass.dll:

  ${NSISBASS_Free}

Notes

The song file is assumed to be in $PLUGINSDIR. You can change this by defining a symbol named NSISBASS_SONGDIR to the base path for your songs (if you have extracted some song to a different location than $PLUGINSDIR).

  !define NSISBASS_SONGDIR "$INSTDIR\hits"

  ;Now as the new base path is defined, let's play our song
  ${NSISBASS_PlayMusic} "macguyver.s3m" 0 0

Return value

After you have !insertmacro'ed some of the macros, you may find "failed" on the top of stack (Pop it). This means that something got screwed up in one of the play macros (NSISBASS_PLAY, NSISBASS_PLAYMUSIC). Check your code and make sure the song file is valid.


Contact

Homepage http://files_saivert.tripod.com/
E-Mail saivert AT email DOT com

Version history

  • version 2.7 (02/27/2008)
    • Updated by Bonk
    • Moved functions in nsisbass.nsh inside macros, added defines to allow for ${} macro call syntax
    • Polished MUI example, used UPX to pack header and noticed a decrease in load time!
  • version 2.6 (02/26/2008)
    • Updated by Bonk
    • Added macros NSISBASS_SETCHANFLAGS and NSISBASS_ERRORGETCODE.
    • Documented macros NSISBASS_PAUSE and NSISBASS_RESUME.
    • Combined $BFNSTREAMHANDLE and $BFNMUSICHANDLE variables into $BFNCHANHANDLE to match changes in BASS 2.3.
    • Added MUI2/nsDialogs example.
  • version 2.5 (02/22/2008)
    • Updated by Bonk
    • Added macros NSISBASS_GETVOLUME, NSISBASS_SETVOLUME and NSISBASS_GETTCPU.
  • version 2.4 (02/11/2008)
    • Updated by Bonk
    • Added macro NSISBASS_PLAYNET (BASS_StreamCreateURL support).
    • Added macro NSISBASS_GETTAGS (BASS_ChannelGetTags support).
    • TODO (still): define and use callback functions properly (playlists support)
  • version 2.3 (01/10/2008)
    • Updated by Bonk
    • Updated for compatibilty with BASS 2.3 (Bass_Init, BASS_ChannelPlay etc.).
    • CD functions removed (now in BASSCD).
    • Renamed include files to nsisbass.nsh and bass.nsh.
    • bass.nsh is now a near complete version of bass.h.
    • Added RESTART and FLAGS parameters to play macros.
    • New examples.
    • TODO: define and use callback functions properly
    • TODO: fill in functionality in nsisbass.nsh for 3D, wma, etc.
  • version 2.0 (04/04/2004)
    • This version breaks previous scripts because I
    • cleaned up syntax a bit, and
    • added a few new System::Call defines for BASS.DLL, so
    • you can check the paused state and pause playback.
    • Also included a whole new example script (NSIS Music Player), you can use instead
    • of Winamp (not that I would do so!).
  • version 1.0 (12/20/2003)
    • first release
    • Still need to know if we have to listen to music when installing stuff...
    • Next release will have everything in BASS.H converted to System::Call syntax.
      • Wanna help me with that?? (Send me an email...)
  • Version 0.01
    • Internal
    • Just playing around with System::Call's
    • Do we really need to listen to music when installing stuff??

Credits

Makes extensive use of the System plugin © brainsucker (Nik Medved)
The BASS Sound System by un4seen.
Readme HTML page design based on work by Joost Verburg.

License

Portions Copyright © 2002-2003:

This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.

Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute
it freely, subject to the following restrictions:

1. The origin of this software must not be misrepresented; 
   you must not claim that you wrote the original software.
   If you use this software in a product, an acknowledgment in the
   product documentation would be appreciated but is not required.
2. Altered versions must be plainly marked as such,
   and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any distribution.