Site icon Learn C++

Learn How To Easily Record Sound In Powerful Modern C++ On Windows

Sounds are in wave format and in digital form sound has its volume change in timeline. In C++ Builder it is easy to use recording devices on Windows. To record a sound in Multi-Device applications we must use FMX.Media.hpp header.

1. Let’s create a new MultiDevice C++ Builder Project, save all project and unit files to a folder.

2. To define Audio Capture Device we need FMX.Media library. Go to Unit1.h header file add

[crayon-68f778f8a9841022867874/]

and lets define Mic device

[crayon-68f778f8a9847229369251/]

3. Let’s back to Unit1.cpp codes, now we can define our Mic device as below

[crayon-68f778f8a9849362169945/]

4. Now we can define FileName directly

[crayon-68f778f8a984c544035078/]

or you can obtain file name by using SaveDialog component as below;

[crayon-68f778f8a984d181865687/]

5. Add a Button now we can start recording device by using StartCapture() as below;

[crayon-68f778f8a984e287133504/]

6. Add another button to stop recording, and stop it as below;

[crayon-68f778f8a9851533174721/]

7. That’s All. Now you can run your codes by pressing F9.

Let’s look at all codes. Unit.h header file should be like this (FMX.Media library is needed);

[crayon-68f778f8a9852279215256/]

Unit.cpp file should be like this;

[crayon-68f778f8a9853688490789/]
Exit mobile version