Sorry to post in both places again but most of my program is in IWB and the problem seems to lie with the API call..
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 an exe file (written in Creative Basic) from a button using the 'system "card.exe" code but also uses music in most of the other modules in IWB using the above calls.
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.
NB EVERY FILE WHEN EXTRACTED IS THE SAME SIZE, SAME NAME, ALL RUN SEPARATELY, AND THE MAIN PROGRAM WORKS OK EXCEPT FOR THE ABSENCE OF SOUND.
If I just copy the whole folder (c:\myprogs\Xmas2012Exe) and paste it into K:\Xmas2012, then everything works fine. I have now made a self extracting zip file (exe) instead using Ken Ward's Zipper program and this seems to work fine.
What might be going wrong in the installation process that 'mutes' all my music files?
I am more interested in any explanation why the program cannot access the mp3 files. I may change the program later and use wave files instead without the API declaration and see if that overcomes the problem with the Excelsior installer.
UPDATE: does exactly the same thing to GWS's program DX example. There must be an incompatibility with the Installation program and the use of this type of file and API call.
??? ??? ??? ???
UPDATE: If I put all the files in a Zip file (Ken Ward's Zipper program) and extract them to a folder on K:\ then all works. So I guess it must be something that the Installer does. What is weird is that ALL the files are there, all exactly the same size, in both folders, nothing apparently corrupted. I still don't understand it!
Two pieces of info you provided tell me one reason why the music doesn't play:
musicfile2=getstartpath+"nOELCAMPAGNE.mp3"
and
(K:\program files\Xmas2012).
the folder you put it in has a space in the folder name.
that means that GETSTARTPATH is returning a path that has a space in it.
mciSendStringA("Play " + musicfile2,"",0,0)
which equates to
mciSendStringA("Play K:\program files\Xmas2012\nOELCAMPAGNE.mp3","",0,0)
when the player parses that command it sees "play' and "K:\program"
change
musicfile2=getstartpath+"nOELCAMPAGNE.mp3"
to
musicfile2="\""+getstartpath+"nOELCAMPAGNE.mp3"+"\""
like I showed you in the sample I provided about embedding mp3s.
BTW, why didn't you embed all those files instead of having them separate?
if you like, email me all your source code and files and I'll fix it up for you right quick.
forgot to mention.
when helping people out I put their code in a folder named c:\!!test
the two !! cause the folder name to be the first folder listed in windows explorer.
the problem I just discovered is that the mp3 player doesn't like those !! and causes your program to quit responding and the music never plays.
Thanks Larry! I can see now why the music files were not playing as an installation package puts everything by default in the c:/program files directory while a zip file can be unzipped anywhere and usually goes to a directory without a space in the name! I will try the revised code later today.
I've also found that several friends I have sent the program to have had problems due to some versions of Windows 7 not having the d3drm.dll file, so in any case I thought it was easier to give up on mp3 for this year and I've replaced the music files with wav ones and playwave, which works fine of course.
UPDATE.... I'd forgotten just how large wave files are! The zip file was 70 Mb with wav, 12 Mb with mp3s!
Most people with few computer skills run a mile when you tell them to copy a dll file into the windows/system32 file, so it is probably better if I avoid the need for that. A pity when GWS's falling snow scene is so good. (Just thought, is it sufficient to put the dll file the program's root directory instead?)
I would like to send you a copy of my original code... just to see how I should go about embedding the mp3 files. That would be enormously helpful. I could then use the code for future programs. That would be really helpful when you have time. (I will do that later today)
I decided not to embed the music files this time as they were relatively large files and I worried about the exe file becoming 'too big', perhaps an illogical fear!
Sorry to bother you again, Larry, but although the revised 'path' code now works fine in my main IWB program, using it in Graham's program in CB seems to lose the sound. I am at a loss to understand why. Any thoughts would be very much appreciated.
(I attach a zip file of my 'main' IWB program.)
:)
' Creative Basic - A Simple Direct X Window
def w:window
def style,n,n1,run:int
def fx,fy:float
def dx,dy,fxnew,fynew:float
def musicfile: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"+"\""
' OLD LINE musicfile = getstartpath + "AngesDeNosCamps.mp3"
mciSendStringA("Play " + musicfile,"",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
mciSendStringA("Close "+ musicfile,"",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
Hi,
Creative only requires:
musicfile=getstartpath+"AngesDeNosCamps.mp3"
Backslashes and stuff upset things. 'getstartpath' is the string specifying the opening folder, and is placed in front of the filename to give the complete path to the music file.
all the best, :)
Graham
The problem is, Graham, that if I use the code in that form, although it performs perfectly well in most situations, when I put the exe file in an installation program which extracts to C:\program files\myfile.exe then it fails to play.
As Larry has suggested: "the folder you put it in has a space in the folder name. That means that GETSTARTPATH is returning a path that has a space in it.
mciSendStringA("Play " + musicfile2,"",0,0)
which equates to
mciSendStringA("Play K:\program files\Xmas2012\nOELCAMPAGNE.mp3","",0,0)
when the player parses that command it sees "play' and "K:\program", not K:\program files.
As musicfile2="\""+getstartpath+"nOELCAMPAGNE.mp3"+"\""
works fine in IWB I might try to code your dx program in IWB, which will probably take me some considerable time! I suppose the easiest thing is to get the installation program to extract to a directory name without a space in it and check that that will be ok.
UPDATE: I just did the obvious thing and made my installation file extract all to a root directory called \xmascard. That solves everything! So just WHY do Microsoft want us to have folder names with spaces in them? Whatever was wrong with c:\ProgramFiles???
thanks,
;D
Oh I see - the API doesn't like spaces in it's path string - what a nuisance. ::)
Simplest thing then, is to unpack to a folder "C:\Xmas2012" or somesuch, under the C:\ root - it works fine then ..
all the best, :)
Graham
I've just done that Graham, and as you say, everything now works perfectly. The simplest solutions are always the best! Why did Microsoft ever think folder names with spaces were a good idea? You could never do that in the 'good old days'. I rather liked file names that were limited to eight characters too! Forced you think hard about naming them!
Thanks for the help. I've now put my installation file at http://www.loire-gites.eu/xmas/xmas12.exe so that it should be much easier for friends and family to download and run it, as well as remove it after Xmas.
Thanks for your help and advice!
;D ;D
Glad it worked for you .. :)
'Why did Microsoft ever think folder names with spaces were a good idea? - indeed - and why did they think storing important program information in a 'Registry' was a good idea?
The old method of having a notepad editable 'ini' file for each piece of software - each program keeping to it's own installation folder - was much safer too. And a lot easier to get rid of anything you no longer wanted. Just delete it's files from your disk.
Nowadays, software seems to spread itself all over your hard disk during installation - usually without asking permission.
I think it's because they let loose too many inexperienced, too clever, youngsters to develop software, which becomes like a Gordian knot.
best wishes, :)
Graham
Quote from: AdrianFox on December 09, 2012, 03:52:32 AM
Sorry to bother you again, Larry, but although the revised 'path' code now works fine in my main IWB program, using it in Graham's program in CB seems to lose the sound. I am at a loss to understand why. Any thoughts would be very much appreciated.
(I attach a zip file of my 'main' IWB program.)
:)
Since you didn't furnish all the files need to compile your IWB project there is nothing I can do with it.
If you subtitute the card .exe call in your iwb program with the adrian1.exe file I posted in the CB section after adding it to your resource and using the extractresource routine that I've provided in several places then everything should work fine.