Beep a sound
Results 1 to 7 of 7

Thread: Beep a sound

  1. #1
    Senior Member
    Join Date
    Jul 2003
    Posts
    166

    Post Beep a sound

    Hi all,
    I need help with generating sound in c++ or asm. But the sound not from the speakers, but from the motherbother. I tried
    mov ax, 0x0e07
    xor bx, bx
    int 0x10
    But when i compile raised an error "Access violation"

  2. #2
    Senior Member
    Join Date
    Oct 2003
    Posts
    111
    This would all depend upon the motherboard, and chipset...
    What type is it? AMD? Intel?...that all makes a difference, as they all have different access restrictions.

    Post some specs, and I'll try to help you out...I'm not great with ASM, but I'm a dabbler
    Creating further mindless stupidity....through mindless automation.

  3. #3
    Senior Member
    Join Date
    May 2003
    Posts
    472
    are u in win, lin or DOS??
    guru@linux:~> who I grep -i blonde I talk; cd ~; wine; talk; touch; unzip; touch; strip; gasp; finger; mount; fsck; more; yes; gasp; umount; make clean; sleep;

  4. #4
    AO Curmudgeon rcgreen's Avatar
    Join Date
    Nov 2001
    Posts
    2,716
    It probably only works in DOS, or a DOS window, because the int 10h is
    a BIOS service, not available to a protected mode program.

    I know it won't work in linux, because I've tried, but probably won't in windows
    either. Do it like this

    write a source file like this.

    Code:
    N       BEEP.COM     
    A       100
    MOV     AX,0E07      ;Write character 07h TTY mode
    INT     10           ;BIOS video services
    INT     20           ;Terminate program (and return to DOS)
    
    RCX
    7
    W
    Q
    Be sure to include a final carriage return at the end of the file
    then assemble it with DEBUG

    Code:
    C:\junk\html>debug<beep.txt
    You will see this screen output.

    Code:
    =N       BEEP.COM
    =A       100
    11CF:0100 MOV     AX,0E07      ;Write character 07h TTY mode
    11CF:0103 INT     10           ;BIOS video services
    11CF:0105 INT     20           ;Terminate program (and return to DOS)
    11CF:0107
    =RCX
    CX 0000  :7
    =W
    Writing 0007 bytes.
    =Q
    and BEEP.COM will be assembled. You can then execute it from the command line
    or from windows by double clicking.

    Code:
    C:\junk\html>beep
    
    C:\junk\html>
    You should hear the beep, or default bell sound

    EDIT!

    I found it! In C it is.

    Code:
    printf("\a");
    duh!
    I came in to the world with nothing. I still have most of it.

  5. #5
    Senior Member
    Join Date
    Jul 2003
    Posts
    166
    10x ... i tried and it works ... but only with debug ... it raised the same error when i use it in c++
    BGDevS
    [gloworange]www.peaksoft.info [/gloworange]

  6. #6
    Senior Member
    Join Date
    Jul 2003
    Posts
    166
    Exuse me ... i mean in borland c++ builder and i can't use printf there 'cause i build visual program not console
    BGDevS
    [gloworange]www.peaksoft.info [/gloworange]

  7. #7
    AO Curmudgeon rcgreen's Avatar
    Join Date
    Nov 2001
    Posts
    2,716
    Code:
    // Introductory lesson to C++
    #include <iostream.h>
    
    /* This is the main function.
    It is included on every C++ program.
    It is the central point of a C++ application.*/
    
    main()
    {
        cout << '\t' << "- Borland C++ Builder -\a" << endl;
        cout << "This will end our session today" << "\n";
    
        cout << "\n\nPress any key to continue...";
        getchar();
    }
    It is the

    cout << "\a";

    statement that works in C++

    http://www.visualcomponentlibrary.com/cpp/Lesson01.htm
    :cool:
    I came in to the world with nothing. I still have most of it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •