PureBasic Forum
http://forums.purebasic.com/english/

How to include soundmodule in exe
http://forums.purebasic.com/english/viewtopic.php?f=10&t=46012
Page 1 of 1

Author:  xperience2003 [ Sun Apr 10, 2011 6:44 am ]
Post subject:  How to include soundmodule in exe

...by extreme easy way^^


Code:

; *************************************
;  Module in exe - PB 4
; *************************************

If InitAudio() And InitPTModule(0) And InitFile(0) 

  ;write module to ram
  length.l=?moddataend-?moddata                                         ;
  ;get module adress
  *jo=?moddata

  If CreateFile(0,"Ram:test.mod")       
    For i=0 To length/4
      WriteLong(PeekL(*jo+(i*4)))
    Next
    CloseFile(0)
  Else
    PrintN("Can't Allocate file.")
  EndIf
 
  AllocateAudioChannels(15)
  UseAsPTModuleChannels(15)
  LoadPTModule(0,"Ram:test.mod")
  PlayPTModule(0)

  Repeat
    VWait() : VWait()
    mb.w=MouseButtons()
  Until mb.w

  StopPTModule()
 
Else
  PrintN("Can't do anyhing^^")
EndIf

 End


;DataSection   <- don't use it will be crash ^^
moddata:
IncludeBinary "codebench:purebasic/examples/sources/test.mod"
moddataend:
;EndDataSection



problems:
- a module of 50kb doesn't work ..10-20kb was ok
- WriteByte doesn't work..i don't know why ..so i use WriteLong ^^

Page 1 of 1 All times are UTC + 1 hour
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/