Sounds and musics

This is a discussion on Sounds and musics within the C Programming forums, part of the General Programming Boards category; Hi, I am not asking how to play music in C. I once tried a program which plays its music ...

  1. #1
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020

    Sounds and musics

    Hi,

    I am not asking how to play music in C. I once tried a program which plays its music through the system bell using different pitches, which actually created a tune. In other words, it doeesn't use my speakers at all.

    Do you know where i can learn to do that? Or any sites with examples?

    THnx

  2. #2
    www.entropysink.com
    Join Date
    Feb 2002
    Posts
    605

    Re: Sounds and musics

    Originally posted by Nutshell
    Hi,

    I am not asking how to play music in C. I once tried a program which plays its music through the system bell using different pitches, which actually created a tune. In other words, it doeesn't use my speakers at all.

    Do you know where i can learn to do that? Or any sites with examples?

    THnx
    You might find music easier in c# (j/k)

    You need to write to port 42h, 43h, and 61h. Try here.
    Visit entropysink.com - It's what your PC is made for!

  3. #3
    Registered User Nutshell's Avatar
    Join Date
    Jan 2002
    Posts
    1,020
    Hi thnx

    But do you or anybody else has any sites that have downloadable examples that actually work?

  4. #4
    Unregistered
    Guest
    hi

    you can download "fmod".. thatīs a c/c++ lib for wave, mod blabla..
    i donīt got the adress, just search in google or something..

    /anders

  5. #5
    www.entropysink.com
    Join Date
    Feb 2002
    Posts
    605
    Originally posted by Nutshell
    Hi thnx

    But do you or anybody else has any sites that have downloadable examples that actually work?
    I think the example on the site I linked was for Borland, cos it used outportb. I don't know how you do it otherwise, cos I haven't got the experience, and couldn't find any "sensible" examples. Most were in assembler.
    Visit entropysink.com - It's what your PC is made for!

  6. #6
    www.entropysink.com
    Join Date
    Feb 2002
    Posts
    605
    Originally posted by Unregistered
    hi

    you can download "fmod".. thatīs a c/c++ lib for wave, mod blabla..
    i donīt got the adress, just search in google or something..

    /anders
    True, but Nutshell specifically implied through the internal speaker, not through a sound card.
    Visit entropysink.com - It's what your PC is made for!

  7. #7
    Registered User
    Join Date
    Apr 2002
    Posts
    3
    sorry , i don't know about it, because i am at beginner level , But this question is really very interesting. Anyhow i will inform yu about it whenever i got a clue


    Awais

  8. #8
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,584
    To play sound/music through the sound card you will need to learn quite a bit about how sound cards work.

    If you wish to do this in DOS, you have a long road ahead of you. However once you get the jist of it, it's not hard.

    For DOS you need to learn about the PIC, DMA, hardware interrupts, and the sound card ports. For information on the actual sound card go to www.creative.com developers section and click on Legacy sound card support - or something to do with legacy SDKs.

    For information about programming the DMA, PIC, and for info on the correct ports look up Ethan Brodsky on www.google.com. He has a very good doc/code example. He has left some things out that were mentioned in the SB document and his code did not work on my machine.

    To mix samples, I simply add the byte or word from each sample and divide by number of samples. This is called additive mixing and while it does not give the best results, it does work.

    To avoid the popping sound, use auto-intialized DMA and a circular buffer. Always play the portion of the buffer you just loaded. So while you are playing one portion, you are loading another. This way there is never an interruption in the sound stream and since you are using auto-init DMA, you are not reprogramming the DMA. You will understand this when you get more info.

    Incidentally, this is how DirectSound also works. Each sample is mixed into the master sample (the one played through the card) very fast. It probably does not use additive mixing though.

  9. #9
    Registered User
    Join Date
    Dec 2001
    Posts
    206

    Re: Re: Sounds and musics

    Originally posted by RobR


    You might find music easier in c# (j/k)

    You need to write to port 42h, 43h, and 61h. Try here.

    uhhh whats the include file for outpotb?

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21