-2

I have my console program in C++ I wonder if I can just use a recorded clip when a "cout" is used example:

cout<<"HI" //while this happens I also want it to play a sound which is prerecorded by me

I don't know if similar questions are on web but I want to know correctly

πάντα ῥεῖ
  • 85,314
  • 13
  • 111
  • 183
  • "I don't know if similar questions are on web" Have you tried searching? People have [asked](https://stackoverflow.com/questions/9961949/playsound-in-c-console-application) about this. There isn't a way in standard C++, so you'd have to look at system calls in whatever platform you're actually running on. – Nathan Pierson Oct 08 '21 at 14:13
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Oct 12 '21 at 13:54
  • after checking a open source assitant i found how to do it – AshishUwU Oct 14 '21 at 03:42

1 Answers1

0

There is no way to make std::cout play a sound when it is written to. You have to code that yourself separately, either before/after the <<, or maybe in parallel using a worker thread. There are plenty of audio playback libraries/APIs readable available for C/C++ if you look around.

Remy Lebeau
  • 505,946
  • 29
  • 409
  • 696