Hick
Hick

Reputation: 36404

Is it possible to work with the sound card a system and produce notes using C language?

I was wondering if its possible to use a sound card , and produce various notes from it using assembly level or C programming language .

Upvotes: 0

Views: 480

Answers (3)

Fredrik Pihl
Fredrik Pihl

Reputation: 45670

See this SO answer Streaming Data to Sound Card Using C on Windows

which points you towards http://www.portaudio.com/

PortAudio is a free, cross-platform, open-source, audio I/O library. It lets you write simple audio programs in 'C' or C++ that will compile and run on many platforms including Windows, Macintosh OS X, and Unix (OSS/ALSA). It is intended to promote the exchange of audio software between developers on different platforms. Many applications use PortAudio for Audio I/O.

PortAudio provides a very simple API for recording and/or playing sound using a simple callback function or a blocking read/write interface. Example programs are included that play sine waves, process audio input (guitar fuzz), record and playback audio, list available audio devices, etc.

Upvotes: 2

JAB
JAB

Reputation: 21089

I'm no expert in sound generation, but... Of course it's possible. Something is needed to make calls to the sound card at some point in any application that uses audio, after all.

However, in almost all cases it's better to make calls to an API, and let the existing sound card driver of the system do all the busywork. Much more portable (...to an extent, at least), and much easier.

http://www.linux.com/archive/feature/113775 might have some good info. For Windows Vista/7, you can check out http://msdn.microsoft.com/en-us/library/dd370784%28v=vs.85%29.aspx.

Oh, and in many cases you'd be better off using an existing software library that can produce the notes rather than trying to generate the waveforms yourself. (See Fredrik's answer.)

Upvotes: 0

Russki
Russki

Reputation: 39

Yes, it is possible. Implementation of that will greatly depend on the system you will be coding for.

You're generally will have a choice to work with DAC (digital to analog converter) output, or, possible, accessing MIDI.

Upvotes: 0

Related Questions