Sound Generation problem C
-
I want to play sound through different channels, i.e. left and right speakers independently, is there any function in C or can you outline the rough procedure of how to go about it...for e.g. to play 440Hz through the left speaker and simultaneously play a 447 Hz sound through the right speaker, can anyone help me accomplish this?? Also, if you can help me play mp3 or wav file using C, without summoning any other program?
-
I want to play sound through different channels, i.e. left and right speakers independently, is there any function in C or can you outline the rough procedure of how to go about it...for e.g. to play 440Hz through the left speaker and simultaneously play a 447 Hz sound through the right speaker, can anyone help me accomplish this?? Also, if you can help me play mp3 or wav file using C, without summoning any other program?
playing mp3 (Copy & paste, Save the source file as .C, not.CPP, won't compile)
#include <cstdlib>
#include <windows.h>
#pragma comment(lib, "Winmm")
#pragma comment(lib, "Vfw32")
#include <vfw.h>
#include <Mmsystem.h>LPCWSTR lpFileName = L"c:\\file.mp3";
int wmain(int argc, char **argv)
{
PlaySound(lpFileName, NULL, SND_FILENAME);
return 0;
}playing wav (Copy & paste, Save the source file as .C, not.CPP won't compile)
#include <stdio.h>
#include <stdlib.h>
#include <Windows.h>#pragma comment(lib,"Winmm.lib")
int main(void)
{
PlaySound("c:\\file.wav",NULL,SND_FILENAME);return 0;
}
-
I want to play sound through different channels, i.e. left and right speakers independently, is there any function in C or can you outline the rough procedure of how to go about it...for e.g. to play 440Hz through the left speaker and simultaneously play a 447 Hz sound through the right speaker, can anyone help me accomplish this?? Also, if you can help me play mp3 or wav file using C, without summoning any other program?
You could use DirectShow[^] if your target system is Windows, it isn't exactly something one can grasp in a minute but it isn't too hard either and there are a lot of samples and documentaton, i am quite sure it can do what you want.
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > If it doesn't matter, it's antimatter.<
-
playing mp3 (Copy & paste, Save the source file as .C, not.CPP, won't compile)
#include <cstdlib>
#include <windows.h>
#pragma comment(lib, "Winmm")
#pragma comment(lib, "Vfw32")
#include <vfw.h>
#include <Mmsystem.h>LPCWSTR lpFileName = L"c:\\file.mp3";
int wmain(int argc, char **argv)
{
PlaySound(lpFileName, NULL, SND_FILENAME);
return 0;
}playing wav (Copy & paste, Save the source file as .C, not.CPP won't compile)
#include <stdio.h>
#include <stdlib.h>
#include <Windows.h>#pragma comment(lib,"Winmm.lib")
int main(void)
{
PlaySound("c:\\file.wav",NULL,SND_FILENAME);return 0;
}
For the record, I pasted this code into a .CPP source file and it compiles with no problems.
Unrequited desire is character building. OriginalGriff