I have taken to heart the comments of qword and others.
I am not rewriting my whole program; what I am doing is writing a small program (testp), using better programming style, designed just to debug the specific problem described in Topic "Child Window Makes Parent Inactive - Another try"
But I have run into an unrelated problem: Beep doesn't work.
erbeep:
mov eax,0B0 ; duration of the sound, in milliseconds
mov ebx, eax ; trial & error
shl eax, 4 ; freq in hertz 0B0 shl 4 = 0B00
invoke Beep,eax,ebx
retn
The identical code works in my big program, but not in the new small one.
The includes are identical. Debugging lfw.exe, I hear the beep when I execute the invoke. Not in testp.exe.
Any idea what could be wrong?
I would also be grateful for any suggestions as to what else I might do to improve programming style.
Thanks, ral
; 2KHz, 50ms
invoke Beep,2000,50
This sounds are really irritating - you may better use the default sounds coming with Windows: MessageBeep (http://msdn.microsoft.com/en-us/library/ms680356(v=vs.85).aspx)
Quote from: qWord on August 12, 2011, 12:53:20 PM
; 2KHz, 50ms
invoke Beep,2000,50
This sounds are really irritating - you may better use the default sounds coming with Windows: MessageBeep (http://msdn.microsoft.com/en-us/library/ms680356(v=vs.85).aspx)
I prefer my frequency and duration. But your code made me realize how silly it was to use the registers.
Thanks, ral
i sometimes use different tones so i can test more than one thing at a time
for things that are going to occur frequently, i use a higher pitch with a shorter duration
for not-so-frequent events, lower tones with longer duration
There is a best soluce (I find)
http://www.soundjay.com/beep-sounds-1.html
Quote
;in ressource file , 530 WAVE DISCARDABLE "nom.wav"
;include winmm.lib et winmm.inc
; invoke SonWav,530
;les macros chr$ et FUNC font parties de MASM32
;################################################################
SonWav PROC IDwave:DWORD
Local retour:DWORD
Local hResInfo:DWORD,hRes,lpRes,bRtn
mov retour,0
; Find the resource
mov hResInfo,FUNC(FindResource,hInstance, IDwave,chr$("WAVE"))
.if eax == 0
wavechec:
jmp FindeSonWav
.endif
;--------------------
mov hRes,FUNC(LoadResource,hInstance, hResInfo)
.if hRes == NULL
jmp wavechec
.endif
mov lpRes,FUNC(LockResource,hRes)
.if lpRes != NULL
mov bRtn,FUNC(sndPlaySound,lpRes, SND_MEMORY + SND_SYNC + SND_NODEFAULT)
;invoke UnlockResource,hRes ;obsolete pas necessaire en 32 bits
mov retour,eax
.endif
;------------------------
invoke FreeResource,hRes
FindeSonWav:
mov eax,retour
ret
SonWav endp
ToutEnMasm and dedndave:
Excellent suggestions, but of limited immediate use, since Beep doesn't work at all in testp.
In the meantime I am learning dialog boxes so I can enter and test different values without repeated reassemblies.
Thanks, ral
Well there is also more compatable way.
You can also adjust freq. in this example
Just call SuperBeep, Freq.
.686
.xmm
.model flat,stdcall
option casemap:none
include windows.inc
include user32.inc
include kernel32.inc
include winmm.inc
includelib user32.lib
includelib kernel32.lib
includelib winmm.lib
AUDIO_STREAM_LEN equ 1
PCM_DATA_SIZE equ (44100 * 2 * AUDIO_STREAM_LEN)
PCM_RAW_SIZE equ (PCM_DATA_SIZE + 44)
.data
fTwoPi dq 6.28
fNormFactor dq 44100.0
fAmpFactor dq 32767.5
pPcmHeader db "RIFF"
dd PCM_DATA_SIZE + 36
db "WAVE"
db "fmt "
db 16, 0, 0, 0, 1, 0, 1, 0
dw 44100
db 0, 0
dw 44100
db 0, 0, 2, 0, 16, 0
db "data"
dd PCM_DATA_SIZE
.data?
pPcmRaw dd ?
.code
SuperBeep PROC uses edi ecx nFreq:DWORD
LOCAL dwTmp:DWORD
finit
mov edi, pPcmRaw
add edi, 44
mov ecx, PCM_DATA_SIZE / 2
@@:
mov eax, PCM_DATA_SIZE / 2
sub eax, ecx
mov dwTmp, eax
fild nFreq
fld fNormFactor
fdiv
fld fTwoPi
fild dwTmp
fmul
fmul
fsin
fld fAmpFactor
fmul
fistp dwTmp
mov eax, dwTmp
stosw
loop @B
invoke PlaySound, NULL, 0, SND_PURGE
invoke PlaySound, pPcmRaw, 0, SND_SYNC or SND_MEMORY
ret
SuperBeep Endp
start:
finit
invoke GetProcessHeap
invoke HeapAlloc, eax, HEAP_ZERO_MEMORY, PCM_RAW_SIZE
mov pPcmRaw, eax
push esi
push edi
mov edi, pPcmRaw
mov esi, offset pPcmHeader
mov ecx, 11
rep movsd
pop edi
pop esi
invoke SuperBeep, 400
invoke GetProcessHeap
invoke HeapFree, eax, NULL, pPcmRaw
invoke ExitProcess, -1
end start
Quote from: Geryon on August 12, 2011, 08:13:26 PM
Well there is also more compatable way.
You can also adjust freq. in this example
Just call SuperBeep, Freq.
[
Thank you.
I'm sorry I have not made myself clear.
I am not looking for a better beep; I am looking for one that works.
I am not trying to compose a string quartet, I want a debugging tool that will let me know whether keyboard input is being processed.
I am quite happy with what I get from
invoke beep,0b00,0b0
But I get it only in one program and not (nothing) in another.
I attached the program in which it doesnt work in the initial post in this topic.
I suspect that there is some sort of environmental difference, since qword said my beeps were irritating, whereas I get no beeps at all with either his values (2000,50) or mine (0b00,0b0).
Thanks, ral
[later] I don't find anything about a "superbeep" function in the SDK docunentation or on the msdn site.
Ral,
if you do not hear the sound, the program is probably not getting to that point in the code
that is, assuming it is a valid audible tone frequency and duration
you can use this fact to help troubleshoot your code
copy/paste the Beep call earlier into the code until you can hear it :U
Geryon,
that is very interesting code
although, using WAVE format seems like overkill
wouldn't it be better to generate a MIDI sound, instead ?
it's not like we are trying to play a symphony - lol
do you have a similar example of how to make sounds with an in-memory MIDI format ?
actually - the format looks pretty simple
maybe i can figure it out :P
Quote from: dedndave on August 12, 2011, 09:10:58 PM
Ral,
if you do not hear the sound, the program is probably not getting to that point in the code
that is, assuming it is a valid audible tone frequency and duration
Well, the first thing I tried was to set a breakpoint at invoke Beep,0b00,0b0 and, with a different assembly, invoke Beep,2000,50 in my debugger (WinDbg - yes I know I should probably be using OllyDbg).
Debugging lfw.exe the code works fine, but debugging testp.exe, nothing (as I think I said in a previous post).
ps to qword: is the 2000, 2000h = 8192d 0r 2000d = 7d0h?
All my code and comments unless otherwise noted are radix 16.
Thanks, ral
[later] correction: the first version I tried, and what I posted had
erbeep:
pushad
mov eax,0B0 ;[in] Duration of the sound, in milliseconds
push eax
shl eax, 4 ;0b0 shl 4 = 0b00 [and later 200 shl 4 = 2000]
push eax
call Beep
popad
retn
But this doesn't seem to make any difference except in style and efficiency.
Quote from: dedndave on August 12, 2011, 09:10:58 PM
Ral,
if you do not hear the sound, the program is probably not getting to that point in the code
Exactly. Here is a primitive macro that might help you...
nclude \masm32\include\masm32rt.inc
MyBeep MACRO arg
ifndef continueBoxes
.data
continueBoxes dd IDOK
.code
endif
.if continueBoxes==IDOK
MsgBox 0, "&arg", "Hi", MB_OKCANCEL
mov continueBoxes, eax
.endif
ENDM
.code
AppName db "Masm32:", 0
start:
MyBeep A
nop
MyBeep B
nop
MyBeep C
nop
MyBeep D
nop
exit
end start
Well, I tried something else.
I put a call erbeep
in the initialization part of the program, leaving the call in the key routine in WProc.
Both reach erbeep, but from initailization it works. From key it doesn't. Both reach invoke Beep,0b00,0b0. One beeps the other not.
What could be going on?
Thanks, ral
[later] There is also a jz erbeep
in newwin if CreateWindow fails. If I set a breakpoint there and manually set zf. again the invoke Beep is reached, but doesn't beep.
This one works fine, it beeps like hell. But I had to convert the radix16 stuff... ::)
Quote from: jj2007 on August 12, 2011, 11:18:04 PM
This one works fine, it beeps like hell. But I had to convert the radix16 stuff... ::)
Well, as I said, the erbeep called from initialization works for me. The erbeep called from key on key "w', hex 57 doesn't work in my program and your program didn't change the hex 57 to 85d. To key in 57d = 39h I pressed "9" in your program and that crashed. I added your
include \masm32\include\masm32rt.inc
to my program and it didn't help.
I don't think this helps, but I really appreciate your effort.
Thanks, ral
Also
You changed my
scrbf DB 50*25 DUP (" ") ;screen buffer, 25 rows, 50 columns
to
scrbf DB 50h*25 DUP (" ") ;screen buffer, 25 rows, 50 columns
.
Shouldn't that have been "50h*25h"? That's probably why there is garbage on lines 19h = 25d through 24h = 36d in your program.
You also didn't change
cmdl DB 40 DUP (?) ;not used -
ps LABEL DWORD ;PAINTSTRUCT
DD 10 DUP (?)
The first wouldn't matter; I'm not sure about the second.
What was your reason for removing the "Radix 16" and adding the "h"es anyway. I don't understand.
Thanks, ral
Ral,
one thing i might suggest......
as we mentioned before, the EBX, EBP, ESI, and EDI registers should be preserved
and the EAX, ECX, and EDX registers may be altered
well, windows functions follow these same rules
that includes Beep :P
in order that you may insert the erbeep routine almost anywhere (anywhere flags need not be preserved).....
erbeep:
push eax
push ecx
push edx
invoke Beep,0B00h,0B0h
pop edx
pop ecx
pop eax
retn
Quote from: dedndave on August 13, 2011, 02:45:58 AM
Ral,
one thing i might suggest......
as we mentioned before, the EBX, EBP, ESI, and EDI registers should be preserved
and the EAX, ECX, and EDX registers may be altered
well, windows functions follow these same rules
that includes Beep :P
in order that you may insert the erbeep routine almost anywhere (anywhere flags need not be preserved).....
erbeep:
push eax
push ecx
push edx
invoke Beep,0B00h,0B0h
pop edx
pop ecx
pop eax
retn
You are absolutely right - a hasty oversight on my part. But it still doesn't work after correction.
Actually the difference would not show up at the invoke, but only after the return if I needed eax, ecx, or edx preserved, and in each case there was nothing to save.
Thanks, ral
the one problem that i can see is that you use the same WndProc for all windows
then, at the beginning of WndProc....
WProc proc wp_hWnd,uMsg,wParam,lParam
pushad
mov eax, [wp_hWnd]
mov [hwnd], eax
this overwrites the hwnd value every time a different window uses the proc
i am not sure this is a problem - lol - it just looks suspicious :red
the functions you have inside the WndProc function make the code difficult to follow
it would be easier if the code was modularized
i can see the advantage in doing it that way - the WndProc parameters are local to everyone and need not be passed :bg
An interesting question regarding jj2997's program:
What happens if the OS (BeginPaint) tries to write 16d bytes to a 10d byte buffer - at the very end of the .DATA? segment?
usually, nothing will happen
but, it's not good :P
the sections are blocks of 512 bytes in the file
and i believe they are assigned blocks of 4096 bytes when loaded into memory
if it were a hard error, Dr Watson would come up
i am able to create the first window
but, when i try to create another, the program crashes silently
this is usually caused by a stack misalignment, but i can't find it
Quote from: dedndave on August 13, 2011, 03:07:56 AM
the one problem that i can see is that you use the same WndProc for all windows
then, at the beginning of WndProc....
WProc proc wp_hWnd,uMsg,wParam,lParam
pushad
mov eax, [wp_hWnd]
mov [hwnd], eax
this overwrites the hwnd value every time a different window uses the proc
i am not sure this is a problem - lol - it just looks suspicious :red
the functions you have inside the WndProc function make the code difficult to follow
it would be easier if the code was modularized
i can see the advantage in doing it that way - the WndProc parameters are local to everyone and need not be passed :bg
Well, my understanding of this stuff is pretty thin, but it seems to me that I have 2 windows, main with CProc, and child with CWProc.
But this makes me think of a possible danger of using global variables; suppose the OS calls WProc again while I am processing a previous call. Could it do that?
Thanks, ral
it can and does - lol
here is the cure for that
inside WProc, use the local variable named wp_hWnd in the function calls (like BeginPaint, etc) instead of hwnd
this one especially :bg
invoke DefWindowProc,wp_hWnd,uMsg,wParam,lParam
then, you can remove these lines...
mov eax, [wp_hWnd]
mov [hwnd], eax
Quote from: dedndave on August 13, 2011, 03:12:11 AM
usually, nothing will happen
but, it's not good :P
the sections are blocks of 512 bytes in the file
and i believe they are assigned blocks of 4096 bytes when loaded into memory
if it were a hard error, Dr Watson would come up
i am able to create the first window
but, when i try to create another, the program crashes silently
this is usually caused by a stack misalignment, but i can't find it
Ah, a clue.
Mine crashes too, but not until I press a key in the child.
And I see why! It is stack misalignment. CWProc CALLS ckey, but then JMPs back.
Changing the call to a jmp fixes that problem!
Still no beep, though.
Thank you! ral
Quote from: dedndave on August 13, 2011, 03:35:03 AM
it can and does - lol
here is the cure for that
inside WProc, use the local variable named wp_hWnd in the function calls (like BeginPaint, etc) instead of hwnd
this one especially :bg
invoke DefWindowProc,wp_hWnd,uMsg,wParam,lParam
then, you can remove these lines...
mov eax, [wp_hWnd]
mov [hwnd], eax
Another great suggestion. I'll do it.
Thank you again!
dedndave: I'm going to give up on the beep problem. I don't really need tha beeps.
I'll go back to the real problems:
1 Getting the child to show properly, and
2. Getting the main window to redisplay after the child does invoke SetFocus,hwnd (in light of your earlier suggestion, I guess I should put CWProc inside WProc and use invoke SetFocus,wp_hWnd)
But can windows procedures be nested? Will the OS be able to find a proc declared locally?
If I do that I might as well put erbeep inside too. Maybe that will fix the erbeep problem,
Thanks, ral
well - the beep thing is interesting, also
but, i understand what you are saying
i have looked at the documentation for using winmm to play a midi file, as well as the docs for creating a midi in memory
it is more than i want to dive into at the moment :bg
i remember creating midi files for a morse code beeper many years ago - it didn't seem that hard
i will come back to it later
there is a need for a good beep routine because newer OS's don't support the Beep API function
the MIDI file format is ideal for this
Assembler Error 02144 cannot nest procedures.
So much for that.
Thanks, ral
Quote from: raleeper on August 13, 2011, 04:23:10 AM
Assembler Error 02144 cannot nest procedures.
So much for that.
But I see the answer - in CWProc use the handle passed passed in.
Thanks, ral
I'm getting groggy. I must have hit Quote rather than Modify.
Sorry, ral
That works.
And the child shows properly, given that it's very undeveloped.
But I have to destoy it to get the main to redisplay.
Thanks, ral
:U
in the mean time, i have been playing with Beep :lol
here is my new TstBeep.inc
i will make it a midi player some day
TstBeep PROTO :DWORD
.CODE
TstBeep PROC nNote:DWORD
;plays musical notes from 37 to 4435 Hz
;higher notes are played for shorter durations
;(duration = 6 to 600 mS)
;Call With: EAX = 1 to 84 (84 plays 4435 Hz for 6 mS)
;
;All registers and flags are preserved.
pushfd
push eax
push ecx
push edx
test byte ptr [esp+13],4 ;DF
jz TBeep0
cld
TBeep0: mov eax,nNote
mov ecx,84
or eax,eax
jnz TBeep1
inc eax
TBeep1: cmp eax,ecx
mov edx,0AAAAAAABh
jbe TBeep2
xchg eax,ecx
TBeep2: dec eax
mov ecx,eax
mul edx
shr edx,3
imul eax,edx,12
sub ecx,eax
movzx eax,word ptr __Tones[2*ecx]
mov ecx,6
sub ecx,edx
xor edx,edx
shr eax,cl
adc eax,edx
xchg eax,ecx
mov eax,22175
div ecx
shl edx,1
cmp edx,ecx
cmc
adc eax,1
INVOKE Beep,ecx,eax
pop edx
pop ecx
pop eax
popfd
ret
ALIGN 2
__Tones dw 2349,2489,2637,2794,2960,3136,3322,3520,3729,3951,4186,4435
TstBeep ENDP
Quote from: dedndave on August 12, 2011, 09:10:58 PM
Geryon,
that is very interesting code
although, using WAVE format seems like overkill
wouldn't it be better to generate a MIDI sound, instead ?
it's not like we are trying to play a symphony - lol
do you have a similar example of how to make sounds with an in-memory MIDI format ?
actually - the format looks pretty simple
maybe i can figure it out :P
I'm glad you liked it and you are right. It's a overkill. Actually, I've wrote this code in C++ a long time ago for using my sound card as a signal synthesizer.
I don't remember MIDI format but I will work on it
Quote from: raleeper on August 13, 2011, 03:09:11 AM
An interesting question regarding jj2997's program:
What happens if the OS (BeginPaint) tries to write 16d bytes to a 10d byte buffer - at the very end of the .DATA? segment?
Nothing happens, as the .data? section has 4096, pardon:1000h bytes. But of course that's an error, and at the same time it shows the problems of idiosyncratic programming styles. Using
.radix 16 looks cool but it does not really help teamwork :bg
Quote from: jj2007 on August 13, 2011, 07:54:40 AM
Nothing happens, as the .data? section has 4096, pardon:1000h bytes. But of course that's an error, and at the same time it shows the problems of idiosyncratic programming styles. Using .radix 16 looks cool but it does not really help teamwork :bg
jj2007: I am working on reducing the idiosyncrasy of my code. But I really had no idea that radix 16 was unusual. My programming methods have developed over a long period with little contact with the programming community. I am very strictly an amatuer. When I began programming it was machine language on a Z80. Decimal made absolutely no sense for that. If you program in hex you rarely have to convert to decimal, and when you do I think the conversion...well we all have calculators now. I don't have to use mine very often. But that's not the point. This is one of my programming methods that I don't think I could ever change. I will think about how much trouble it would be to write (and debug!) a small program that would take an asm program done in hex and convert it to decimal. Such a program may already have been done.
Anyway I do appreciate the considerable effort you expended just trying to help.
[later] I just noticed the "jj2997". I apologize and assure you it was in no way intentional. I meant to type 2007 - That's very easy to remember.
Quote from: raleeper on August 13, 2011, 09:23:47 AM
When I began programming it was machine language on a Z80. Decimal made absolutely no sense for that.
Ral,
I guess we are about the same age then ;-)
No problem, nobody insists that you change your style; the only aspect to reflect on is that getting help is easier if the helper understands your code. Many people here do use hex notation in programming, but as 1000h under the standard radix. Most GUI code has a high share of decimal notation - difficult with radix 16. Adding a trailing h under radix 10 is easier...
Take care,
Jochen
Quote from: dedndave on August 13, 2011, 05:13:56 AM
:U
in the mean time, i have been playing with Beep :lol
here is my new TstBeep.inc
i will make it a midi player some day
Looks good. But aren't we talking about the motherboard or case speaker, here? Could that ever be high quality enough for music?
[file under /beep /cr synthesizer]
Quote from: jj2007 on August 13, 2011, 10:05:24 AM
. Adding a trailing h under radix 10 is easier...
Hmmm. Yes, How much trouble is that, really? I'll consider.
But would that make the code much more palatable to people who do not like hex?
And I can see some cases where even if I am in radix 16 I should use a d suffix [probably a better way to put that] - How many bytes or tchars should I allocate for the user's answer to this question? I don't think in hex there.
Something to think about.
Thanks, ral
Quote from: raleeper on August 13, 2011, 10:23:47 AM
But aren't we talking about the motherboard or case speaker, here? Could that ever be high quality enough for music?
It depends on how you define "high quality".
http://www.masm32.com/board/index.php?topic=1789.0
http://www.masm32.com/board/index.php?topic=6790.0
you can make music through the pc speaker
and, since the original pc, they have been making game sound effects
i used musical tones because they are easier on the ear, really
and - no need to have that many different tones, so why not space them out musically
i included the flats and sharps - that is probably more than is needed
as for the radix issue
i think we all tried radix 16, at some point
and we quickly learned that it is not as attractive as it sounds
the reason is, that you are going to want to use a mixture of base 10 and base 16 values (and in some cases base 2)
while the computer may see 1's and 0's, and hex seems native to the CPU,
base 10 is native to the human world :bg
Quote from: dedndave on August 13, 2011, 03:49:17 PM
i used musical tones because they are easier on the ear, really
That's a matter of taste, Dave - see attachment. The good news is it works :bg
Quote from: dedndave on August 13, 2011, 03:49:17 PM
you can make music through the pc speaker
and, since the original pc, they have been making game sound effects
i used musical tones because they are easier on the ear, really
and - no need to have that many different tones, so why not space them out musically
i included the flats and sharps - that is probably more than is needed
Good reasons! And you might possibly want to use the app for a first draft or rough notes.
Quoteas for the radix issue
i think we all tried radix 16, at some point
and we quickly learned that it is not as attractive as it sounds
the reason is, that you are going to want to use a mixture of base 10 and base 16 values (and in some cases base 2)
while the computer may see 1's and 0's, and hex seems native to the CPU,
base 10 is native to the human world :bg
OK
Hex is second nature to me; I'v been using it for something like 1c years (But no, I'm not completely crazy).
I have to add a "d" once in a while, but adding "h"s would be a huge pain and error source, unless a translation program exists. I could write one. In fact I would add it to lf.exe [DOS], which already has a command that saves the current (LF format file), pushes a backup, and translates and saves an ascii .asm version. I never assemble any other way. It would not be hard to add a number filter and "h" adder. But if not perfect, it would be a big error source, I think.
Does radix 16 make my code significantly less friendly for others?
I had never thought about this until jj2007 brought it to my attention.
Thanks
for me, i am used to the form "0DABEh" :bg
after reading miles of ms documentation, i have also become accustomed to "0xDABE", although i like the 'h" better
over time, you will see that you want to mix decimal constants with hex about 50/50
Jochen,
nice demo
for some reason, i didn't think your voice was that low :lol
i notice you used mciSendString
any examples of using it with in-memory data ?
it looks like smaller code than using mciSendCommand
if we use a MIDI format, we can get small :P
Quote from: dedndave on August 13, 2011, 06:31:58 PM
it looks like smaller code than using mciSendCommand
if we use a MIDI format, we can get small :P
mciExecute (http://msdn.microsoft.com/en-us/library/dd757154%28v=vs.85%29.aspx) is even smaller:
invoke mciExecute, chr$("play MyFile.mp3")
Unfortunately, midi files seem not to work.
yah - you probably have to tell it to go to the sequencer
anyways - we want to generate the data in memory, then send it
Quote from: dedndave on August 13, 2011, 07:31:40 PM
yah - you probably have to tell it to go to the sequencer
anyways - we want to generate the data in memory, then send it
If you have spare time, check this... (http://home.roadrunner.com/~jgglatt/tech/lowmidi.htm)
that's some really old stuff - lol
i wish he had more up-to-date info
i bet he knows his way around pretty well
Dave,
Our friends in Redmond say it can be done in a few lines, see below, but it doesn"t work :'(
Quoteinclude \masm32\MasmBasic\MasmBasic.inc
; include \masm32\include\masm32rt.inc
include \masm32\include\winmm.inc
includelib \masm32\lib\winmm.lib
.code
start:
print "press Esc to exit", 13, 10 ; MSDN (http://support.microsoft.com/kb/171980)
.Repeat
; invoke mciSendString, chr$("open ", 34, "D:\masm32\examples\bcraven\playmidi\sample.mid", 34, " type sequencer alias sample"), 0, 0, 0
invoke mciSendString, chr$("open D:\masm32\examples\bcraven\playmidi\sample.mid type sequencer alias sample"), 0, 0, 0
; invoke mciSendString, chr$("open 'D:\masm32\examples\bcraven\playmidi\sample.mid' type sequencer alias sample"), 0, 0, 0
deb 4, "Open", eax
; .if eax
invoke mciSendString, chr$("play sample wait"), 0, 0, 0
deb 4, "Play", eax
invoke mciSendString, chr$("close sample"), 0, 0, 0
deb 4, "Close", eax
; .else
; print LastError$(), 13, 10
; .endif
getkey
.Until al==27
print "bye"
exit
end start
Jochen,
open up your volume mixer and make sure the SW Synth level isn't all the way down or muted
i got it to work with a file using a single call to mciSendString
INVOKE mciSendString,chr$('play \masm32\examples\bcraven\playmidi\sample.mid'),
NULL,NULL,NULL
i don't think i can play from a memory location that way
i may have to use a few calls to mciSendCommand, or use the midi functions
Quote from: dedndave on August 14, 2011, 08:37:37 AM
Jochen,
open up your volume mixer and make sure the SW Synth level isn't all the way down or muted
i got it to work with a file using a single call to mciSendString
INVOKE mciSendString,chr$('play \masm32\examples\bcraven\playmidi\sample.mid'),
NULL,NULL,NULL
i don't think i can play from a memory location that way
i may have to use a few calls to mciSendCommand, or use the midi functions
Perfect, it works. Thanks, Dave :U
i see that the sw synth level keeps setting itself to 0
here is what i can gather after searching....
the SW Synth volume level is, of course, in the system registry
many midi files set the volume for the different midi channels
after playing a midi file with windows media player or many other programs,
the Synth volume level is reset to the value it was at boot
so, to get a change to remain, you set the level and reboot before playing a midi file
there is probably an easy registry edit, but i cannot seem to find it on the web
on another note.....
mciSendString is probably not the way to go, anyways
there is a noticible delay between the execution time and the time the sound occurs - lol
my understanding is that i do not need a midi file at all - even in memory
by using the winmm midi functions, i can send data strings directly to the synth to make sounds
Quote from: dedndave on August 14, 2011, 04:01:55 PM
mciSendString is probably not the way to go, anyways
there is a noticible delay between the execution time and the time the sound occurs - lol
Right. However, to make it work for an "acoustic messagebox", you can
open it at progstart and call the play command when you need it. There is no delay for
play.
I attach an extra-long beep for you. Sorry, can't push it below 1,536 bytes :bg
oh - i think you can make any musical beep you want in a file less than 128 bytes
the one drawback of midi files - everything has to be fricken musical - lol
Quote from: dedndave on August 15, 2011, 12:53:52 AM
oh - i think you can make any musical beep you want in a file less than 128 bytes
the one drawback of midi files - everything has to be fricken musical - lol
The 1,536 referred to the executable, not the midi file - ok, I admit the example is really a bit gaga :P