News:

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

Sending Byte to Speaker

Started by Farabi, April 22, 2009, 01:07:06 AM

Previous topic - Next topic

Farabi

Anyone one know how to send data to Audio card? Of course using Windows API.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

UtillMasm

// a chinese music: Song Bie 送别 送別 :wink

// BeepMusic.cpp : Defines the entry point for the console application.
//

#include "windows.h"

#define ONE_BEEP    600
#define HALF_BEEP    300

#define NOTE_1      440
#define NOTE_2      495
#define NOTE_3      550
#define NOTE_4      587
#define NOTE_5      660
#define NOTE_6      733
#define NOTE_7      825
#define NOTE_NONE    Sleep(ONE_BEEP);


int main(int argc, char* argv[])
{
  Beep(NOTE_5, ONE_BEEP);
  Beep(NOTE_3, HALF_BEEP);
  Beep(NOTE_5, HALF_BEEP);
  Beep(NOTE_1*2, ONE_BEEP*2);

  Beep(NOTE_6, ONE_BEEP);
  Beep(NOTE_1*2, ONE_BEEP);
  Beep(NOTE_5, ONE_BEEP*2);

  Beep(NOTE_5, ONE_BEEP);
  Beep(NOTE_1, HALF_BEEP);
  Beep(NOTE_2, HALF_BEEP);
  Beep(NOTE_3, ONE_BEEP);
  Beep(NOTE_2, HALF_BEEP);
  Beep(NOTE_1, HALF_BEEP);
  Beep(NOTE_2, ONE_BEEP*4);

  Beep(NOTE_5, ONE_BEEP);
  Beep(NOTE_3, HALF_BEEP);
  Beep(NOTE_5, HALF_BEEP);
  Beep(NOTE_1*2, HALF_BEEP*3);
  Beep(NOTE_7, HALF_BEEP);
  Beep(NOTE_6, ONE_BEEP);
  Beep(NOTE_1*2, ONE_BEEP);
  Beep(NOTE_5, ONE_BEEP*2);

  Beep(NOTE_5, ONE_BEEP);
  Beep(NOTE_2, HALF_BEEP);
  Beep(NOTE_3, HALF_BEEP);
  Beep(NOTE_4, HALF_BEEP*3);
  Beep(NOTE_7/2, HALF_BEEP);
  Beep(NOTE_1, ONE_BEEP*4);

  Beep(NOTE_6, ONE_BEEP);
  Beep(NOTE_1*2, ONE_BEEP);
  Beep(NOTE_1*2, ONE_BEEP*2);

  Beep(NOTE_7, ONE_BEEP);
  Beep(NOTE_6, HALF_BEEP);
  Beep(NOTE_7, HALF_BEEP);
  Beep(NOTE_1*2, ONE_BEEP*2);

  Beep(NOTE_6, HALF_BEEP);
  Beep(NOTE_7, HALF_BEEP);
  Beep(NOTE_1*2, HALF_BEEP);
  Beep(NOTE_6, HALF_BEEP);
  Beep(NOTE_6, HALF_BEEP);
  Beep(NOTE_5, HALF_BEEP);
  Beep(NOTE_3, HALF_BEEP);
  Beep(NOTE_1, HALF_BEEP);
  Beep(NOTE_2, ONE_BEEP*4);

  Beep(NOTE_5, ONE_BEEP);
  Beep(NOTE_3, HALF_BEEP);
  Beep(NOTE_5, HALF_BEEP);
  Beep(NOTE_1*2, HALF_BEEP*3);
  Beep(NOTE_7, HALF_BEEP);
  Beep(NOTE_6, ONE_BEEP);
  Beep(NOTE_1*2, ONE_BEEP);
  Beep(NOTE_5, ONE_BEEP*2);

  Beep(NOTE_5, ONE_BEEP);
  Beep(NOTE_2, HALF_BEEP);
  Beep(NOTE_3, HALF_BEEP);
  Beep(NOTE_4, HALF_BEEP*3);
  Beep(NOTE_7/2, HALF_BEEP);
  Beep(NOTE_1, ONE_BEEP*3);
  return 0;
}

##############################################

Microsoft Windows Software Development Kit Update for Windows Vista
  C:\Program Files\Microsoft SDKs\Windows\v6.0\Bin\SetEnv.Cmd
   Shortcut
    Target
      C:\Windows\System32\cmd.exe /E:ON /V:ON /T:0E /K "C:\Program Files\Microsoft SDKs\Windows\v6.0\Bin\SetEnv.Cmd" /Release /x86 /vista
    Start in:
      C:\china\

C:\china>cl BeepMusic.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 14.00.50727.762 for 80x86

Copyright (C) Microsoft Corporation.  All rights reserved.

BeepMusic.cpp
Microsoft (R) Incremental Linker Version 8.00.50727.762
Copyright (C) Microsoft Corporation.  All rights reserved.

/out:BeepMusic.exe
BeepMusic.obj

C:\china>

[attachment deleted by admin]

BogdanOntanu

UtilMASM,

This is an ASM forum.

Please avoid posting C/C++ or other programming languages code in here.

Ambition is a lame excuse for the ones not brave enough to be lazy.
http://www.oby.ro

UtillMasm

Ok, sorry, but translate it to masm version 6.14.8444 is not difficulty.
I will do that, when i got some time.

UtillMasm

;ChinaMusic.asm
;C:\china>\masm32\bin\ml /c /coff /Cp /I\masm32\include ChinaMusic.asm
;Microsoft (R) Macro Assembler Version 6.14.8444
;Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.
;
; Assembling: ChinaMusic.asm
;
;C:\china>\masm32\bin\link /subsystem:windows /libpath:\masm32\lib ChinaMusic.obj
;Microsoft (R) Incremental Linker Version 5.12.8078
;Copyright (C) Microsoft Corp 1992-1998. All rights reserved.
;
;
;C:\china>
.386
.model flat,stdcall
include kernel32.inc
includelib kernel32.lib
.code
start:push 258h
push 294h
call Beep
push 12Ch
push 226h
call Beep
push 12Ch
push 294h
call Beep
push 4B0h
push 370h
call Beep
push 258h
push 2DDh
call Beep
push 258h
push 370h
call Beep
push 4B0h
push 294h
call Beep
push 258h
push 294h
call Beep
push 12Ch
push 1B8h
call Beep
push 12Ch
push 1EFh
call Beep
push 258h
push 226h
call Beep
push 12Ch
push 1EFh
call Beep
push 12Ch
push 1B8h
call Beep
push 960h
push 1EFh
call Beep
push 258h
push 294h
call Beep
push 12Ch
push 226h
call Beep
push 12Ch
push 294h
call Beep
push 384h
push 370h
call Beep
push 12Ch
push 339h
call Beep
push 258h
push 2DDh
call Beep
push 258h
push 370h
call Beep
push 4B0h
push 294h
call Beep
push 258h
push 294h
call Beep
push 12Ch
push 1EFh
call Beep
push 12Ch
push 226h
call Beep
push 384h
push 24Bh
call Beep
push 12Ch
push 19Ch
call Beep
push 960h
push 1B8h
call Beep
push 258h
push 2DDh
call Beep
push 258h
push 370h
call Beep
push 4B0h
push 370h
call Beep
push 258h
push 339h
call Beep
push 12Ch
push 2DDh
call Beep
push 12Ch
push 339h
call Beep
push 4B0h
push 370h
call Beep
push 12Ch
push 2DDh
call Beep
push 12Ch
push 339h
call Beep
push 12Ch
push 370h
call Beep
push 12Ch
push 2DDh
call Beep
push 12Ch
push 2DDh
call Beep
push 12Ch
push 294h
call Beep
push 12Ch
push 226h
call Beep
push 12Ch
push 1B8h
call Beep
push 960h
push 1EFh
call Beep
push 258h
push 294h
call Beep
push 12Ch
push 226h
call Beep
push 12Ch
push 294h
call Beep
push 384h
push 370h
call Beep
push 12Ch
push 339h
call Beep
push 258h
push 2DDh
call Beep
push 258h
push 370h
call Beep
push 4B0h
push 294h
call Beep
push 258h
push 294h
call Beep
push 12Ch
push 1EFh
call Beep
push 12Ch
push 226h
call Beep
push 384h
push 24Bh
call Beep
push 12Ch
push 19Ch
call Beep
push 708h
push 1B8h
call Beep
push 0
call ExitProcess
end start

Farabi

Can Beep Function play a raw WAV format?
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

UtillMasm

I don't know that.
That source music Song Bie is mp3 song, not wav.

donkey

"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

Farabi

Quote from: donkey on April 22, 2009, 10:34:55 AM
Quote from: Farabi on April 22, 2009, 10:19:48 AM
Can Beep Function play a raw WAV format?

The PlaySound function plays WAV format.

No I want to play with audio data, so I need to access the raw data.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Mark Jones

Consider DirectSound then. The DS buffer can be accessed directly and easily, and is available on most PC's.

http://www.masm32.com/board/index.php?topic=5382.0
http://www.masm32.com/board/index.php?topic=10555.0
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

Farabi

Quote from: Mark Jones on April 23, 2009, 05:59:13 PM
Consider DirectSound then. The DS buffer can be accessed directly and easily, and is available on most PC's.

http://www.masm32.com/board/index.php?topic=5382.0
http://www.masm32.com/board/index.php?topic=10555.0

Thanks. Its a good start.
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Farabi

Mark:
Where can I donwload ultrano's lib?
Those who had universe knowledges can control the world by a micro processor.
http://www.wix.com/farabio/firstpage

"Etos siperi elegi"

Mark Jones

I don't know, it would be nice if he still had it available. Perhaps someone here still has it.
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08