Record a WAV file

Record a WAV file

You can use MCI functions if you want to record a WAV file. The main MCI function is mciSendString, that sends command strings to the system and execute them.

Declare Function mciSendString Lib "winmm" Alias "mciSendStringA" (ByVal _    lpstrCommand As String, ByVal lpstrReturnString As String, _    ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long

The first argument is the command string, lpstrReturnString receives return information (if needed), uReturnLength is the number of characters in lpstrReturnString, and hwndCallback is used for system notifications. Remember that every command string described in this tip must be sent to the system as follows:

CommandString = "your MCI command here"RetVal = mciSendString(CommandString, vbNullString, 0, 0&)

The first thing to do when working with WAV files is open the WAV device with this statement:

CommandString = "Open new type waveaudio alias RecWavFile"

where “RecWavFile” is an alias, that is an arbitrary name that you’ll use in the next command strings to refer to a particular MCI memory buffer (and that you later save to disk). Then you can start, pause or resume and stop recording with one of the following statements:

' start recordingCommandString = "Record RecWavFile"' pause recordingCommandString = "Pause RecWavFile "' resume recordingCommandString = "Resume RecWavFile "' stop recordingCommandString = "Stop RecWavFile"

You can also set the time format in milliseconds:

CommandString = "Set RecWavFile time format milliseconds"

and you can record for a number of milliseconds and then terminate:

' record for only 2 secondsCommandString = "Record RecWavFile to 2000 wait"

When you have completed your recording homework, you must save the WAV file to file, which you do with

CommandString = "Save RecWavFile " & FileName

Finally, always remember to close the device with Close command:

CommandString = "Close RecWavFile"

Share the Post:
XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes

ransomware cyber attack

Why Is Ransomware Such a Major Threat?

One of the most significant cyber threats faced by modern organizations is a ransomware attack. Ransomware attacks have grown in both sophistication and frequency over the past few years, forcing

data dictionary

Tools You Need to Make a Data Dictionary

Data dictionaries are crucial for organizations of all sizes that deal with large amounts of data. they are centralized repositories of all the data in organizations, including metadata such as