BB FlashBack SDK: Base Classes |
Recording Sound Sources and Devices
A PC will typically have a sound 'device' for each sound card installed, and each device will have a number of sources available for recording, such as the microphone, PC sounds, line in and others.
FBRecorder allows you to set the sound device and source to record from, but uses a different set of methods and properties for Windows 2000/XP than for Vista.
For help on accessing individual sound tracks in a recording and saving them to files, see How the sound classes work.
Windows 2000/XP
Setting the Sound Device and Source in Windows 2000/XP
Use SoundDevicesCount to get the number of attached recordable sound devices. This gives the range of valid device indexes.
Pass a device index into GetSoundDevice, to get a device ID and name.
Select a sound device
for recording by setting SoundDevice
to the ID of the required device.
Once we've selected a sound device, we follow a similar process to
select a sound source on that device.
Call GetSoundSources to prepare the internal list of sound sources. This call has to be made before using SoundSourcesCount, GetSoundSource and GetSoundSourcesInfo.
Use SoundSourcesCount to get the number of sources available on the selected device. This gives the range of valid source indexes.
Set SoundSource
to the index of the source to be recorded.
Altering source volume or muting sources in Windows 2000/XP
The GetSoundLineVolume and SetSoundLineVolume methods can be used to retrieve and set the recording volume for a particular source on the current device.
The GetSoundLineMuteValue and SetSoundLineMuteValue can be used to mute a source.
The input to these functions is a LineID, returned from GetSoundSource when the source index is passed in.
Getting the index of the Microphone and "PC sounds" sources
To get the index of the current source, microphone and "mix" source (typically the sounds heard in the PC speakers), use GetSoundSourcesInfo.
|
Windows Vista and 7
Retrieving the ID and other information for each sound source
Use VistaSoundSourcesCount to get the number of sound devices and sources available for recording. It returns the total number of sources available for recording across all attached devices. The gives a range of valid indexes that can be passed to GetVistaSoundSource.
Pass an index into GetVistaSoundSource to retrieve information, including the ID, for a device-source combination.
To identify microphone sources:
The "component type" of microphone sources (returned from GetVistaSoundSource) is 4099 (MIXERLINE_COMPONENTTYPE_SRC_MICROPHONE).
To identify the "PC Sounds" source (the sound you hear through the PC speakers)
The "PC Sounds" source has an ID of -1. Retrieve the ID of the source by calling GetVistaSoundSource.
To record a microphone source in Vista:
Set VistaRecordPCSounds to False
Set VistaSoundSource to the ID of the microphone to record. Get the ID by using GetVistaSoundSource to identify the microphone source (see above).
Other properties, such as VistaRecordMicrophone need not be set.
To record the "PC Sounds" source in Vista:
Set VistaRecordPCSounds to True
Set VistaRecordMicrophone to False
Set VistaSoundSourceName
to the name of the PC Sounds source.
Get the name of the source from the SourceFullName property returned
from GetVistaSoundSource.
The "PC Sounds" source always has an ID of -1.
To record a sound source other than "PC Sounds" or a microphone in Vista:
Set VistaRecordPCSounds to False
Set VistaSoundSource to the ID of the source to record, as returned by GetVistaSoundSource.
To record PC Sounds and microphone in Vista
Vista has extra sound functionality that enables recording of the microphone and "PC Sounds" source simultaneously, into different tracks.
Set VistaRecordPCSounds to True
Set VistaRecordMicrophone to True
Set VistaSoundSourceName to the name of the PC Sounds source, as returned in the SourceFullName property by GetVistaSoundSource. The "PC Sounds" source always has an ID of -1. Retrieve the ID of the source by calling GetVistaSoundSource.
Set VistaMicrophoneID to the ID of a microphone source.
Altering source volume or muting sources in Windows Vista
Use GetVistaSoundVolumeValue and SetVistaSoundVolumeValue to alter the volume of sound recording sources. These methods require source IDs. Call GetVistaSoundSource to obtain the source IDs, or get the ID of the microphone source from VistaMicrophoneID.