Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Sound Generation problem C

Sound Generation problem C

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Veeshal Beotra
    wrote on last edited by
    #1

    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?

    S C 2 Replies Last reply
    0
    • V Veeshal Beotra

      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?

      S Offline
      S Offline
      Software_Developer
      wrote on last edited by
      #2

      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;
      

      }

      L 1 Reply Last reply
      0
      • V Veeshal Beotra

        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?

        C Offline
        C Offline
        Code o mat
        wrote on last edited by
        #3

        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.<

        1 Reply Last reply
        0
        • S Software_Developer

          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;
          

          }

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          For the record, I pasted this code into a .CPP source file and it compiles with no problems.

          Unrequited desire is character building. OriginalGriff

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups