Click here to Skip to main content
16,004,977 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionfinding Audio Level Pin
atimpoo3-May-06 21:17
atimpoo3-May-06 21:17 
AnswerRe: finding Audio Level Pin
Nishad S3-May-06 21:26
Nishad S3-May-06 21:26 
AnswerRe: finding Audio Level Pin
Remco Hoogenboezem3-May-06 21:43
Remco Hoogenboezem3-May-06 21:43 
GeneralRe: finding Audio Level Pin
atimpoo3-May-06 23:34
atimpoo3-May-06 23:34 
AnswerRe: finding Audio Level Pin
normanS4-May-06 19:51
normanS4-May-06 19:51 
QuestionRe: finding Audio Level Pin
atimpoo5-May-06 0:00
atimpoo5-May-06 0:00 
AnswerRe: finding Audio Level Pin
normanS7-May-06 19:19
normanS7-May-06 19:19 
AnswerA possible technique Pin
normanS7-May-06 23:11
normanS7-May-06 23:11 
Let's say you have a block of audio data from the microphone (you could use the WaveIn functions - see http://msdn.microsoft.com/library/default.asp?url=/library/en-us/multimed/htm/_win32_waveform_functions.asp[^] .)

The data block has a number of characteristics which you specify, such as block length (50 or 100 milliseconds is reasonable), sampling rate (22 kHz should be OK), sample size (8 or 16 bit per sample), stereo or mono (microphone is probably mono.)

The general procedure I would follow would be:

Long SumOfSamples = 0
Long SumOfSquaredDifferences = 0

// First determine the average sound level
// I don't know whether audio data is represented as unsigned or signed values - 
// you may have to look at the values in a data block to decide what to use!
For count = 1 to numberSamplesInBlock
	SumOfSamples += soundSample[count]

AverageSoundLevel = SumOfSamples / numberSamplesInBlock

// Now work out the average of how far every sample is from the average level
For count = 1 to numberSamplesInBlock
	ThisSampleDifference = sample[count] - AverageSoundLevel
	SumOfSquaredDifferences += ThisSampleDifference * ThisSampleDifference

AverageDifference = SquareRoot(SumOfSquaredDifferences) / numberSamplesInBlock

// Now decide whether the data block is loud or soft or in-between
If AverageDifference < softSoundThreshold
	Display "The Sound Is Soft"
Else if AverageDifference > loudSoundThreshold
	Display "The Sound Is Loud"
Else
	Display "The Sound Is Between Soft And Loud Limits"

// Determine the softSoundThreshold and loudSoundThreshold by recording 
// sounds using the microphone and looking at their AverageDifference values

Questionneed a virtual drive in ram Pin
V_shr3-May-06 21:13
V_shr3-May-06 21:13 
AnswerRe: need a virtual drive in ram Pin
Hamid_RT3-May-06 21:52
Hamid_RT3-May-06 21:52 
GeneralRe: need a virtual drive in ram Pin
V_shr3-May-06 22:02
V_shr3-May-06 22:02 
GeneralRe: need a virtual drive in ram Pin
Nibu babu thomas3-May-06 22:19
Nibu babu thomas3-May-06 22:19 
GeneralRe: need a virtual drive in ram Pin
V_shr3-May-06 22:38
V_shr3-May-06 22:38 
GeneralRe: need a virtual drive in ram Pin
Nibu babu thomas3-May-06 23:42
Nibu babu thomas3-May-06 23:42 
GeneralRe: need a virtual drive in ram Pin
Hamid_RT4-May-06 1:28
Hamid_RT4-May-06 1:28 
GeneralRe: need a virtual drive in ram Pin
V_shr4-May-06 3:26
V_shr4-May-06 3:26 
QuestionSSO from VC++ Pin
HakunaMatada3-May-06 21:04
HakunaMatada3-May-06 21:04 
Questionselecting a device without UI Pin
V_shr3-May-06 21:00
V_shr3-May-06 21:00 
AnswerRe: selecting a device without UI Pin
Cedric Moonen3-May-06 21:08
Cedric Moonen3-May-06 21:08 
GeneralRe: selecting a device without UI Pin
V_shr3-May-06 21:12
V_shr3-May-06 21:12 
GeneralRe: selecting a device without UI Pin
Cedric Moonen3-May-06 21:43
Cedric Moonen3-May-06 21:43 
GeneralRe: selecting a device without UI Pin
V_shr3-May-06 21:52
V_shr3-May-06 21:52 
GeneralRe: selecting a device without UI Pin
Justin Tay3-May-06 21:56
Justin Tay3-May-06 21:56 
GeneralRe: selecting a device without UI Pin
V_shr3-May-06 22:20
V_shr3-May-06 22:20 
GeneralRe: selecting a device without UI Pin
Justin Tay3-May-06 22:33
Justin Tay3-May-06 22:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.