This has baffled me. Any idea why it might be happening.
I have successfully completed my 'Xmas Card' project in which I am using GWS's API call
declare "WINMM",mciSendStringA(command:string,temp:string,length:int,callBack:int),int
The music is played from an mp3 file with
musicfile2=getstartpath+"nOELCAMPAGNE.mp3"
mciSendStringA("Play " + musicfile2,"",0,0)
and closed with
mciSendStringA("Close "+ musicfile2,"",0,0)
The whole program most of which is in IWB, calls the compiled exe file (written in Creative) from a button using 'system "card.exe" but also uses music in most of the other modules in IWB.
I have used the above code successfully throughout the program (both in IWB and Creative) to play various pieces of music and a speech file, all in mp3 format.
I moved the finished compiled program to another directory where I was working ((From C:\myprogs\xmas2012 to c:\myprogs\xmas2012exe ) with just the files needed. (mainly the mp3 files and exe files).
Still FINE and the program runs perfectly as designed.
Now comes the problem. I put all the files in an installation package (Excelsior) and then checked the installation file by extracting them to the main hard disk on my computer. (K:\program files\Xmas2012).
The program runs perfectly except not a sound from any of the music files!
I have tried reinstalling to K:\2012 but still nothing. Have checked all the files are there, and they are, and I can play the mp3 files by just clicking on them.
If I just copy the whole folder (c:\myprogs\Xmas2012Exe) and paste it into K:\Xmas2012, then everything works fine.
What might be going wrong in the installation process that 'mutes' all my music files?
??? ??? ??? ??? ???
I'm posting this here instead of where you posted the qustion in order to try and keep CB separate from IWB although I know the problem is overlapping.
Anyway, here is a version of the CB program you posted that will play MP3s from a path that has a space.
' Creative Basic - A Simple Direct X Window
'this version will play from a folder with a space in the name
def w:window
def style,n,n1,run:int
def fx,fy:float
def dx,dy,fxnew,fynew:float
def musicfile:string
def command:string
type flake
def fx:int
def fy:int
def fspr:int
endtype
declare Rn(low:INT,high:INT)
declare "WINMM",mciSendStringA(command:STRING,temp:STRING,length:INT,callBack:INT),INT
' specify the number of snowflakes ..
n1 = 150
def f[n1+1]:flake :' snowflakes
style = @NOAUTODRAW|@NOCAPTION
window w,-1200,0,1024,768,style,0,"Creative Basic Direct X",main
setwindowcolor w,0
' create a DirectX screen ...
createscreen(w,1024,768,32)
frontpen w,rgb(0,80,120)
setfont w,"Times New Roman",20,400,@SFITALIC
drawmode w, @TRANSPARENT
' play background music ..
REM THE LINE YOU GAVE ME, BELOW, WORKS FINE IN THE IWB PARTS OF MY PROGRAM, BUT USED IN CB HERE
REM THE SOUND DISAPPEARS, EVEN WHEN COMPILED.
musicfile=getstartpath+"AngesDeNosCamps.mp3"
command = "open " +chr$(34)+ musicfile +chr$(34)+ " alias mymidi"
mciSendStringA(command,"",0,0)
command = "play mymidi"
mciSendStringA(command,"",0,0)
run = 1
' load background image ...
if dxnewmap(w,getstartpath + "back.jpg",1024,768,1) = 0
messagebox w, "Could not load the background image","Error"
run = 0
endif
centerwindow w
' create a blank map filled with tile#0 ...
dxcreatemap w,1,1,0
dxdrawmap w
' hide the cursor
setcursor w,@CSCUSTOM,0
for i = 0 to n1
f[i].fx = Rn(100,1000)
f[i].fy = Rn(1,768)
f[i].fspr = dxsprite(w,getstartpath + "flake.bmp",20,20,1,0)
DXSETSPRITEDATA f[i].fspr,@SDBLTTYPE,@BLTTRANSSCALED
DXSETSPRITEDATA f[i].fspr,@SDSCALE, 0.16 + Rnd(0.1) - rnd(0.1)
next i
waituntil run = 0
command = "close mymidi"
mciSendStringA(command,"",0,0)
closewindow w
END
main:
select @CLASS
case @IDDXUPDATE
update
case @IDCLOSEWINDOW
run = 0
case @idchar
' pressing the 'ESC'(ape) key will abort the program ...
key = @CODE
if (key = 27) then run = 0
endselect
return
sub update
'draw the background
dxdrawmap w
for i = 0 to n1
dx = rnd(15.0) - rnd(15.0) + 3
fxnew = f[i].fx + dx
f[i].fx = 0.9*f[i].fx + 0.1*fxnew
dy = rnd(5.0) - rnd(5.0) + 10
fynew = f[i].fy + dy
if (fynew > 850 + rnd(200) - rnd(200))
f[i].fx = Rn(100,1000)
f[i].fy = Rn(-100,1) :' done to get a random flow of flakes from the top of the screen
else
f[i].fy = 0.2*fynew + 0.8*f[i].fy
endif
DXMOVESPRITE f[i].fspr, f[i].fx, f[i].fy
DXDRAWSPRITE w, f[i].fspr
next i
move w,250,640
print w,"Happy Xmas from Sally and Adrian"
move w,200,670
print "Press ESC to Exit"
'show the changes
dxflip w
return
sub Rn(low,high)
' generates a random number between Low and High ..
n = int((high - low + 1) * rnd(1.0) + low)
return n
Many thanks Larry. That works well and will make things easier in the future. Thanks for your time and effort in helping me.
:) :) :) :)
Thanks for that Larry - I couldn't see a way to do it .. ::)
I'm always amazed how you find solutions to tricky problems ;D
Saved in my 'useful programs' file, for future use should it be needed.
all the best, :)
Graham
Here's the final version.
The mp3,jpg, and bmp files are all loaded from a resource file.
source file will not run with green run button; it must be compiled(run with exe button)
that's because you have to have the exe file to add the resource file.
extract the exe zip to an empty folder and run first to prove it doesn't need the other files externally
after extracting the src zip you'll need to modify each of the resource entries to reflect where you unzipped the at in order to be able to recompile.
Had to split the attachments because of size limitations.
Thanks very much for that Larry as that shows me how to embed resources in a way I would never have understood without seeing the working example. (One small point I noticed was that in the Resource file in the zip a space had slipped into the path to locate the files as c:\x mas\"something.mp3" which prevented it compiling, though luckily even I noticed it quickly!))
I must now practise using the code to embed mp3 and other resources. Just wondered though why you put the bmp and jpg files into resources in the same way rather than just using the 'standard' method? Although I can see it is neater in terms of coding.
Am I right in thinking that Graham's simpledx program could be easily ported to IWB with few changes in code other than the 'normal' IWB parameters for windows and controls?
Many thanks again for all your help.
;D
Quote from: AdrianFox on December 10, 2012, 04:05:06 AM
(One small point I noticed was that in the Resource file in the zip a space had slipped into the path to locate the files as c:\x mas\"something.mp3" which prevented it compiling, though luckily even I noticed it quickly!))
it was 'x mas' because I changed the folder name to that so that I could make sure it worked like that.
Quote from: AdrianFox on December 10, 2012, 04:05:06 AM
Am I right in thinking that Graham's simpledx program could be easily ported to IWB with few changes in code other than the 'normal' IWB parameters for windows and controls?
define "easily".
for example
in CB you have
declare TempExtractResource(id:int,ty:int,ex:string)
declare ExtractResource(id:int,ty:int,fn:string)
because subroutines have to be declared before they can be used, and
the subroutines are structured like this:
sub TempExtractResource(id,ty,ex)
def retfn:string
.....
return retfn
and this:
sub ExtractResource(id,ty,fn)
def retc:int
.....
return retc
To convert to IWB you get rid of
declare TempExtractResource(id:int,ty:int,ex:string)
declare ExtractResource(id:int,ty:int,fn:string)
and the subroutines look like this:
sub TempExtractResource(id:int,ty:int,ex:string),string
def retfn:string
.....
return retfn
endsub
and this:
sub ExtractResource(id:int,ty:int,fn:string),int
def retc:int
.....
return retc
endsub