Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 15628

VB6 check for sound on speakers

$
0
0
Hi,

looking at some old code to 'test for silence' on the speakers...

https://www.vbforums.com/showthread....Sound-Tutorial

Comment #4 to 'record sound', although I'm not looking to save anything, just to report if there's sound or not (I'll modify it later).

I've downloaded the zip files and I'm running the code from there, in part:
Code:

Private Sub cmdStartRec_Click()
    Dim ErrReturn As String
    Dim WaveFmt As WaveFormat
   
    ' fill in the Wave Format
    With WaveFmt
        .wFormatTag = 1 ' PCM
       
        .nChannels = 2
        .nSamplesPerSec = 48000  ' from my sound card, was 44100
        .wBitsPerSample = 24          'from my sound card, was16
       
        .nBlockAlign = .wBitsPerSample * .nChannels / 8
        .nAvgBytesPerSec = .nBlockAlign * .nSamplesPerSec
    End With
   
    ' Create the wave tile
    FileNum = FreeFile
    Open "D:\Recording Test.WAV" For Binary Access Write Lock Write As FileNum
   
    WaveWriteHeader FileNum, WaveFmt ' write the wave headers
   
    With DirectSoundRecord
        ' initialize DirectSound with exactly the same sound format as you expect to write in the file
        ErrReturn = .Initialize(WaveFmt.nSamplesPerSec, WaveFmt.wBitsPerSample, WaveFmt.nChannels)
       
        If Len(ErrReturn) = 0 Then
            ' if there was no error
            ' start recording
            .SoundPlay
           
            cmdStopRec.Enabled = True
            cmdStartRec.Enabled = False
        Else
            MsgBox ErrReturn, vbExclamation, "DirectSound Error"
        End If
    End With
End Sub

fails at:
With DirectSoundRecord
ErrReturn = .Initialize(WaveFmt.nSamplesPerSec, WaveFmt.wBitsPerSample, WaveFmt.nChannels)

and reports:
Error: -2147221164
Desription: Class not registered

I have dx8vb.dll registered...any ideas please?

Regards
Peter

Viewing all articles
Browse latest Browse all 15628

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>