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

Hi ,
I have always enjoyed that sound  :biggrin:
How is that sound accessed on a PC?
Is there a was to do that with masm?
Or is it a source with beeps?
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

if you are talking about the "whish" sound like the one Kristanna Loken makes in Terminator 3,
it comes from the modem speaker - it is the actual audio that goes back and forth over the phone

you might be able to google around and get a WAV file of it

http://www.soundjay.com/dial-up-modem-sound-effect.html

WAV files are easy to play and you can add them to your exe as a resource

as far as "enjoying" that sound - lol - i can find you many better things to listen to   :lol:

Magnum

You can do it with Masm, but you'll have to do a lot of experimenting to get the right tones and delays.

Andy


;Telephone.asm
;              Simulate telephone ringing
;              Help from SuperDave -- a.k.a. DednDave,   
;              PRODUCE 1 KHz TONE FOR 54.9 mS
;              PRODUCE 800 Hz TONE FOR 54.9 mS

.486                       ; create 32 bit code
.model flat, stdcall       ; 32 bit memory model
option casemap :none       ; case sensitive

include \masm32\include\windows.inc
include \masm32\include\masm32.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\shell32.inc
includelib \masm32\lib\masm32.lib
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\shell32.lib
include \masm32\macros\macros.asm

.data

.code 
                 
start:

mov ecx, 20
@@:
push ecx
invoke Beep, 1000, 55 ; Frequency in hertz and sound duration
invoke Beep, 800, 55   
pop ecx
dec ecx
jnz @B
invoke Sleep, 1500   

mov ecx, 20
@@:
push ecx
invoke Beep, 1000, 55 ; Frequency in hertz and sound duration
invoke Beep, 800, 55   
pop ecx
dec ecx
jnz @B
invoke Sleep, 1500

mov ecx, 20
@@:
push ecx
invoke Beep, 1000, 55 ;
invoke Beep, 800, 55   
pop ecx
dec ecx
jnz @B

invoke ExitProcess,0

end start

Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

hfheatherfox07

Ok ,
I thought it was like magnum stated

So this is a file that comes with the computer as wav ?

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

For Dave:

mov esi, filebuffer
lea ebx, [esi+FileSize]
.Repeat
   ... ; <<<<<< I can't put the missing instruction here - you know why 8)
   movzx eax, al
   shl eax, 6
   add eax, 127  ; be nice to your speakers
   mov edx, eax
   and eax, 3
   invoke Beep, eax, edx
.Until esi>=ebx

MichaelW

I think that reasonably recreating the sound will be difficult. IIRC after the dialing sequence what you hear is the modems connecting and negotiating a bitrate.
Well Microsoft, here's another nice mess you've gotten us into.

dedndave

after you hit a key, you have to wait for it to finish one pass on the loop   :P

Jochen - i don't get it - lol   :redface:
mov esi, filebuffer
lea ebx, [esi+FileSize]
.Repeat
   ... ; <<<<<< I can't put the missing instruction here - you know why 8)
   movzx eax, al
   shl eax, 6
   add eax, 127  ; be nice to your speakers
   mov edx, eax
   and eax, 3
   invoke Beep, eax, edx
.Until esi>=ebx

jj2007

Quote from: dedndave on January 05, 2013, 10:06:05 AM
Jochen - i don't get it - lol   :redface:
   ... ; <<<<<< I can't put the missing instruction here - you know why 8)

Starts like lol and ends like "banned by Hutch" :biggrin:

And it works - test it!

dedndave

ohhhhhhhhhhhhhhhhh
i get it   :biggrin:

he'd love some of my old 16-bit code - lol
i used to use LODSB, STOSB and LOOP like crazy to parse the command line

; mlx function
;
BU0003: CBW
        MOV     CX,AX           ;char count
        MOV     DL,AH           ;nybble flag
        MOV     BX,300Ah        ;10/'0'
        MOV     DI,OFS BU0000   ;CS:0100
;
; start off in hex mode
;
BU0004: LODSB
        MOV     DH,AL           ;save original
        XOR     AL,BH           ;pay attention
        CMP     AL,BL           ;is it 0-9 ?
        JB      BU0005
;
        AND     AL,0DFh         ;lower case
        SUB     AL,51h          ;(xor'ed 30h)
        CMP     AL,5            ;is it a-f ?
        JA      BU0010          ;no - test literal
;
        ADD     AL,BL           ;yes - adjust it
;
BU0005: OR      DL,DL           ;first nybble ?
        JZ      BU0009
;
        SHL     AH,1            ;no - X 16
        SHL     AH,1
        SHL     AH,1
        SHL     AH,1
        OR      AL,AH           ;code byte
        STOSB
        DEC     DX              ;clear nybble
;
BU0006: LOOP    BU0004
;
BU0007: CMP     DI,OFS BU0000   ;was there any ?
        JZ      BU0002          ;no - date/time
;
; all done - execute the script
;
BU0008: MOV     AX,98B4h        ;align IP
        STOSW
        STOSW
        STOSW
        MOV     AH,4Ch          ;exit with code
        STOSW
        MOV     AX,21CDh        ;INT 21h
        STOSW
        MOV     AX,2000h        ;no parsed parms
        MOV     CLPRM0,AX
        MOV     CLPRM1,AX
        MOV     AH,0Dh          ;cr
        MOV     CLTAIL,AX       ;no tail
        MOV     CLTAIL+2,OFS PRGEND
        MOV     AX,CX           ;zero registers
        MOV     BX,AX
        MOV     DX,AX
        MOV     BP,AX
        MOV     SI,AX
        MOV     DI,AX
        JMP     BU0000          ;hope it works
;
BU0009: MOV     AH,AL           ;first nybble
        INC     DX              ;set flag
        LOOP    BU0004
;
        STOSB
        JMP     BU0008
;
; literal mode
;
BU0010: OR      DL,DL
        JZ      BU0011
;
        MOV     AL,AH
        STOSB
        DEC     DX
;
BU0011: CMP     DH,27h          ;single quote
        JZ      BU0013
;
        CMP     DH,22h          ;double quote
        JZ      BU0013
;
        LOOP    BU0004
;
        JMP     BU0007
;
BU0012: LODSB
        CMP     AL,DH
        JZ      BU0006
;
        STOSB
;
BU0013: LOOP    BU0012
;
        JMP     BU0007

Magnum

Dave,

You can convert that to an .mp3 and shrink that exe.

We don't want no VB sized code.  :t

Take care,
                   Andy

Ubuntu-mate-18.04-desktop-amd64

http://www.goodnewsnetwork.org

dedndave

hey - it's a resource, not code   :biggrin:
i may play with the wav - cut it down to a shorter loop
but - it isn't as easy to run an mp3 as it is a wav file
i can make a smaller wav by reducing the bit-rate
not like it has to be high fidelity - it's a bunch of harmonic noise, to start with

hfheatherfox07

Quote from: Magnum on January 05, 2013, 12:18:23 PM
Dave,

You can convert that to an .mp3 and shrink that exe.

We don't want no VB sized code.  :t

It is not that big  LOL
I posted an example of how to play mp3 from resource here :

http://masm32.com/board/index.php?topic=639.msg5216#msg5216
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: jj2007 on January 05, 2013, 11:33:10 AM
Quote from: dedndave on January 05, 2013, 10:06:05 AM
Jochen - i don't get it - lol   :redface:
   ... ; <<<<<< I can't put the missing instruction here - you know why 8)

Starts like lol and ends like "banned by Hutch" :biggrin:

And it works - test it!
I like the way you show how long the putter being running
Do you have the source for that?
With out masm basic?
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, 06:58:31 PM
I like the way you show how long the putter being running
Do you have the source for that?
With out masm basic?

Heather,
These are business secrets that are thoroughly hidden in \Masm32\MasmBasic\MasmBasic.inc but for you I will reveal them here:

Timer   textequ <TimerMac(@Line)>
TimerMac MACRO MacLine
  if MacLine ne MacLineTimer
   MacLineTimer = MacLine
   push ecx
   invoke GetTickCount
   pop ecx
  endif
  EXITM <eax>
ENDM


Usage:
        Inkey Str$("\n\nYour puter has run %3f hours since the last boot, give it a break!", Timer/3600000)


:biggrin:

hfheatherfox07

@ jj2007
I figured this would not work for me  :(

Console version ( I prefer message box ) :

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

; Description: Generic Win32 Console Application Template 
;
; Revision date:
comment * ¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤
                     Build this as console app
                 
        ¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤ *     
; ¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤   
.486                                      ; create 32 bit code
.model flat, stdcall                      ; 32 bit memory model
option casemap :none                      ; case sensitive

include \masm32\include\windows.inc       ; main windows include file
include \masm32\include\masm32.inc        ; masm32 library include
include \masm32\include\user32.inc
include \masm32\include\gdi32.inc
include \masm32\include\kernel32.inc
include \masm32\include\msvcrt.inc
include \masm32\include\dialogs.inc       ; macro file for dialogs


includelib \masm32\lib\masm32.lib         ; masm32 static library
includelib \masm32\lib\user32.lib
includelib \masm32\lib\gdi32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\msvcrt.lib
   
include \masm32\macros\macros.asm         ; masm32 macro file
; ¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤=÷=¤
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
    invoke SetConsoleTitle, ADDR ConsoleTitle

print "Your puter has run %3f hours since the last boot, give it a break!",13,10 ; Timer/3600000
    ret

main endp
end start


and message Box Version :

.386
.model flat,stdcall
option casemap:none

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

includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\masm32.lib

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
MsgCaption     db "Puter Run Time:",0
MsgBoxText     db "Your puter has run %3f hours since the last boot, give it a break!",0

.data?
Buffer   db   256 dup (?) ; for file size..

.code


.code
start:
invoke TimerMac, ADDR Buffer
invoke wsprintf, addr Buffer, addr MsgBoxText, eax
invoke MessageBox, NULL, addr Buffer, addr MsgCaption, MB_OK
invoke ExitProcess,NULL
end start


I get Errors:

: error A2006: undefined symbol : MacLineTimer
: error A2148: invalid symbol type in expression : TimerMac
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.