News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Dial Up Modem sound

Started by hfheatherfox07, January 05, 2013, 06:54:04 AM

Previous topic - Next topic

hfheatherfox07

@ jj2007  Here is another console attempt... :(
That why I asked if this was with out masmBasic   :(  Too Dificult for me  :(

TITLE  Puter Run Time  [MASM] (Puter.asm)

; Description: Generic Win32 Console Application Template 
;
; Revision date:
comment * ¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤
                     Build this as console app
                 
        ¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤ *     
; ¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤   
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
    include \masm32\include\masm32rt.inc
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
TimerMac MACRO MacLine
  if MacLine ne MacLineTimer
   MacLineTimer = MacLine
   push ecx
   invoke GetTickCount
   pop ecx
  endif
  EXITM <eax>
ENDM

.const

Timer   textequ <TimerMac(@Line)>

.data ; Initialized data section
ConsoleTitle  db "Puter Run Time:",0


.code
; Execution begins here...
start:

    call main
    inkey        ; wait for a keystroke before exiting
    exit




main proc
   LOCAL MacLineTimer :DWORD
   LOCAL Time : DWORD
    invoke SetConsoleTitle, ADDR ConsoleTitle
mov Time, rv(Timer/3600000)    ; use "TimerMac" procedure
      print "Your puter has run "
      print str$(Time)," hours since the last boot, give it a break!",13,10      ; display the results

    ret

main endp
end start


Your code and your skills will be assimilated. Your programming language is irrelevant.
We are the ASM Borg and you will become part of us. Compile and be assembled.

hfheatherfox07

Well Technically GetTickCount does that :
The GetTickCount function retrieves the number of milliseconds that have elapsed since Windows was started.

DWORD GetTickCount(VOID)


Parameters

This function has no parameters.

Return Values

If the function succeeds, the return value is the number of milliseconds that have elapsed since Windows was started.

Remarks

The elapsed time is stored as a DWORD value. Therefore, the time will wrap around to zero if Windows is run continuously for 49.7 days.


But the time is in milliseconds....
I have a proc to convert , But I forgot where ?
.386
.model flat, stdcall
option casemap:none

include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib

.data
szTitle db "Puter Run Time:",0
szformat db "%lu",0 ; time mask
.data?
buftime dd ?
db 4096 dup(?)
.code
start:
    invoke GetTickCount
    invoke wsprintf, addr buftime,addr szformat,eax
    invoke MessageBox,0,addr buftime,addr szTitle,MB_OK
    invoke ExitProcess,0
end start
Your code and your skills will be assimilated. Your programming language is irrelevant.
We are the ASM Borg and you will become part of us. Compile and be assembled.

hfheatherfox07

No Idea how you converted Milliseconds to hours  :(

I know of this but can not get it to work?
   xor eax, eax
   mov ax, mytime.wMilliseconds
   movzx ebx, mytime.wSecond
   movzx ecx, mytime.wMinute
   movzx edx, mytime.wHour
   movzx edi, mytime.wDay
   movzx esi, mytime.wMonth
Your code and your skills will be assimilated. Your programming language is irrelevant.
We are the ASM Borg and you will become part of us. Compile and be assembled.

jj2007

Quote from: hfheatherfox07 on January 05, 2013, 10:24:12 PM
No Idea how you converted Milliseconds to hours  :(

See attachment. GetTickCount is milliseconds since boot, divide by 1000*3600 and you arrive at hours.

hfheatherfox07

I found this thread http://www.masmforum.com/board/index.php?PHPSESSID=786dd40408172108b65a5a36b09c88c0&topic=8647.0

I wish I can get your example to work LOL

Your code and your skills will be assimilated. Your programming language is irrelevant.
We are the ASM Borg and you will become part of us. Compile and be assembled.

dedndave

i have played with modems more than i wanted to - lol
mostly satellite data modems - not the same thing, really
but, i never really got into the audio interface part of a telephone modem
i think they use a few special tones at start-up to negotiate speed, etc
after that, it's probably a form of FSK, using 2 distinct tones
it sounds like more tones because of the sidebands that are generated

so, you could just alternate between 800 and 1200 Hz and just vary the duration
small durations like 1 to 5 mS seem likely
let me play with it a little...

dedndave

that isn't too far off   :P
you need a better random generator, but it gives you a place to start

loop00: INVOKE  GetTickCount
        and     eax,0Fh
        INVOKE  Beep,800,eax
        INVOKE  GetTickCount
        and     eax,0Fh
        INVOKE  Beep,1200,eax
        call    crt__kbhit
        or      eax,eax
        jz      loop00

        call    crt__getch
        INVOKE  ExitProcess,0

hfheatherfox07

Quote from: jj2007 on January 05, 2013, 10:31:08 PM
Quote from: hfheatherfox07 on January 05, 2013, 10:24:12 PM
No Idea how you converted Milliseconds to hours  :(

See attachment. GetTickCount is milliseconds since boot, divide by 1000*3600 and you arrive at hours.

Thanks  jj2007 Got It  :t
How did you format it to get 2.7 hours for example ?
Mine shows to the nearest hour only!
Do I need to calculate for minutes too ?

.386
.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib

.data
MsgCaption      db "PUTER TIME",0
format          db "Your puter has run %d:hours since the last boot, give it a break!",0

.data?
Buffer      db 1024 dup (?)
szHoursVal dword  ?

.code

start:

invoke GetTickCount
   ;Hours
  mov szHoursVal,eax ; store the result of GetTickCount in eax
  mov ebx,3600000
  sub edx, edx          ;set edx to zero
  div ebx
   invoke wsprintf,addr Buffer,addr format, eax
   invoke MessageBox, NULL, addr Buffer, addr MsgCaption, MB_ICONASTERISK

   invoke ExitProcess,NULL
end start
Your code and your skills will be assimilated. Your programming language is irrelevant.
We are the ASM Borg and you will become part of us. Compile and be assembled.

hfheatherfox07

Quote from: dedndave on January 05, 2013, 11:14:59 PM
that isn't too far off   :P
you need a better random generator, but it gives you a place to start



It is 8:04 AM I think I Will go to sleep with some soothing modem sounds  :lol:
Your code and your skills will be assimilated. Your programming language is irrelevant.
We are the ASM Borg and you will become part of us. Compile and be assembled.

dedndave

here is how it sounds with a little better random generator

you could try tone pairs other than 800 and 1200 Hz

hfheatherfox07

@dedndave
you seem to enjoy this beep stuff ....
I found a MorseCode example you might like  :biggrin:

Kýsa-dit.wav  is Short Dit

Uzun-dit.wav is Long Dit

KDit       equ    2003
UDit       equ    2004

The English change if you want is
SDit          equ    2003
LDit          equ    2003

Snippet:

invoke PlaySound,LDit,hInstance,SND_RESOURCE
   jmp short stimer
s_psg:
   invoke PlaySound,SDit,hInstance,SND_RESOURCE
Your code and your skills will be assimilated. Your programming language is irrelevant.
We are the ASM Borg and you will become part of us. Compile and be assembled.

dedndave

thanks - it's funny you mention that   :biggrin:

i would like to find a way to play a MIDI sound from memory
i think it can be done, i just need to spend some time playing with the "mci" functions

that way, i can create variable-length, variable-pitch dits and dahs on the fly

hfheatherfox07

Quote from: dedndave on January 14, 2013, 09:00:08 AM
thanks - it's funny you mention that   :biggrin:

i would like to find a way to play a MIDI sound from memory
i think it can be done, i just need to spend some time playing with the "mci" functions

that way, i can create variable-length, variable-pitch dits and dahs on the fly

(Musical Instrument Digital InterfaceStandard) MIDI Files ("SMF" or *.mid files)

I am confused ? Do you mean play .mid ?
If by from memory you mean from res , that is easy ... I have a felling that is not what you mean from memory
Your code and your skills will be assimilated. Your programming language is irrelevant.
We are the ASM Borg and you will become part of us. Compile and be assembled.

dedndave

yes - a .MID file - only from memory, not from a file

all the examples i have seen create a file from resource, then play it from the file
i want to play it directly from a memory buffer

EDIT - it may be that i just need to send tone information, not an actual MID format

jj2007

Quote from: dedndave on January 14, 2013, 09:17:34 AM
i want to play it directly from a memory buffer

QuoteCheck the MIDIplyr sample in VC6. If I remember correctly it plays out of a file buffer.

There is also some stuff here.

Warning "this code requires Windows '95" ;-)