News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Beep

Started by raleeper, August 12, 2011, 12:24:46 PM

Previous topic - Next topic

raleeper

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.

jj2007

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

raleeper

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]

raleeper

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


MichaelW

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

eschew obfuscation

dedndave

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

jj2007

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

raleeper

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

dedndave

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

jj2007

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 is even smaller:
invoke mciExecute, chr$("play MyFile.mp3")

Unfortunately, midi files seem not to work.

dedndave

yah - you probably have to tell it to go to the sequencer
anyways - we want to generate the data in memory, then send it

jj2007

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...

dedndave

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

jj2007

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
   .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

dedndave

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