Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <m_std\\iostr.h> //iostr is the standard IO lib for music studios C++ lib
- #include <m_std\\report.h> //report is the standard report for music studios C++ lib
- #include <m_std\\thread.h> //thread is the standard thread for music studios C++ lib
- int main()
- {
- std::INSTREAM* istream = (std::INSTREAM*)new std::STREAM.create("IN_DEVICE"); // creates an input stream
- std::OUTSTREAM* ostream = (std::OUTSTREAM*)new std::STREAM.create("OUT_DEVICE"); // creates an output stream
- std::AUDIOSTREAM* astream = (std::AUDIOSTREAM*)new std::STREAM.create("AUDIO_DEVICE", L"ALL"); // creates an audio stream
- if (astream->aSize() == 0) // if the audio stream has no devices
- {
- std::REPORTER.set("Audio Report", "Could not find any audio streams to record from.");
- std::STREAM.forceClose(L"ALL"); // forcing all streams to close
- return 0;
- }
- if (astream->streams.isNull(istream) || astream->streams.isNull(ostream)) // tries to attach both the input and output streams, but as well return if they were null
- {
- std::REPORTER.set("Audio Report", "Could not create an input or output for the audio stream.");
- std::STREAM.forceClose(L"ALL"); // forcing all streams to close
- return 0;
- }
- while (astream->recordAudio("STATUS") == "NO_RECORD") // while the audio stream is not recording
- {
- astream->waitForInput(std::M_THREAD.getSleep()); // sleep the time necessary for lowest cpu usage as possible
- }
- astream->attachDevice("STD_DEVICE", "INPUT"); // attach the input device for recoding
- while (astream->recordAudio("STATUS") == "AUDIO_IN") // while the audio stream is recording
- {
- astream->create(); // create a buffer and attach recorded sound to the buffer created. if a buffer exists it will add to that
- }
- astream->detachDevice("STD_DEVICE", "INPUT"); // detachs the input device again
- astream->attachDevice("STD_DEVICE", "OUTPUT"); // attachs the output device
- std::MEDIASTREAM* mstream = (std::MEDIASTREAM*)new std::STREAM.create("MEDIA"); // creates a media stream
- mstream->setMediaType(L"P_AUDIO", L"M_AUDIO", L"N_MP3"); // sets all audio media types, except for mp4 though it's possible using the MP4STREAM instead
- astream->attachOutput(mstream->getStream()); // attachs the media stream to the audio stream
- while (mstream->isPlay()) // while the media stream is playing (it's now associated with the buffer from the audio stream
- {
- if (mstream.reachPoint != NULL) // if the reach point is not null
- if (mstream.reachPoint == std::MPOINT.end) // if the reach point is the end of the media
- if (mstream.replay) // if the media should replay
- mstream.position = 0; // set the media position to 0 (start)
- astream->create(); // create a buffer for dislaying (sound in this case), if the buffer exists it will add sound to it
- }
- astream->detachDevice("STD_DEVICE", "OUTPUT"); // detach the output device
- delete mstream; // deletes the media stream since it's not bound to the std streams (the reason is that the media stream has to be attached to another stream
- std::STREAM.forceClose(L"ALL"); // forcing all streams to close
- if (std::REPORT.get() != NULL) // checks if the report has any data ex. invalid devices etc.
- return std::REPORT.important("ERROR_CODE"); // returns the most important error code
- return 0;// success
- }
Add Comment
Please, Sign In to add comment