Solved

WIN 95 MMSYSTEM.dll function calls

Posted on 1997-09-07
4
228 Views
Last Modified: 2013-12-03
Which Functions from mmsystem.dll are (in which sequence) necessarry to get the samples from a soundcard?
Do I have to use waveinstart, waveinopen, wavein....
The purpose is to 1. Reduce the access to the soundcard to
a mmsystem.dll function call(s).
2. I want to process the data afterwards and I don't need
continuous sampling but single samples from both channels
(left and right). I'm using a graphical development environment which allows dll function calls.
And where to find information about these things are done?


0
Comment
Question by:pertex
  • 2
  • 2
4 Comments
 
LVL 5

Expert Comment

by:y96andha
ID: 1406045
Do you want to sample data from the sound card? If so, what do you want to do with the samples, save to disk or process?
0
 

Author Comment

by:pertex
ID: 1406046
Edited text of question
0
 
LVL 5

Accepted Solution

by:
y96andha earned 200 total points
ID: 1406047
This is source in Visual Basic to record 1 second of 8kHz mono. This should show both the sequence of the calls, and the parameters needed in the structures. Please comment if you have any questions.

Dim wf As WAVEFORMATEX
Dim hWaveIn As Long
Dim error As Long
wf.wFormatTag = WAVE_FORMAT_PCM
wf.nChannels = 1
wf.nSamplesPerSec = 8000
wf.wBitsPerSample = 8
wf.nBlockAlign = wf.nChannels * wf.wBitsPerSample / 8
wf.nAvgBytesPerSec = wf.nSamplesPerSec * wf.nBlockAlign
wf.cbSize = 0
error = waveInOpen(hWaveIn, WAVE_MAPPER, wf, 0, 0, 0)
If error <> 0 Then
    Print "Error "; error; " in waveInOpen"
    Exit Sub
End If

Dim wh As WAVEHDR
Dim data(8000) As Byte
wh.lpData = VarPtr(data(1))
wh.dwBufferLength = 8000
wh.dwUser = 0
wh.dwFlags = 0
wh.dwLoops = 0
wh.lpNext = 0
wh.Reserved = 0
error = waveInPrepareHeader(hWaveIn, wh, Len(wh))
If error <> 0 Then
    waveInClose hWaveIn
    Print "Error "; error; " in waveInPrepareHeader"
    Exit Sub
End If

error = waveInAddBuffer(hWaveIn, wh, Len(wh))
If error <> 0 Then
    waveInUnprepareHeader hWaveIn, wh, Len(wh)
    waveInClose hWaveIn
    Print "Error "; error; " in waveInAddBuffer"
    Exit Sub
End If

error = waveInStart(hWaveIn)
If error <> 0 Then
    waveInReset hWaveIn
    waveInUnprepareHeader hWaveIn, wh, Len(wh)
    waveInClose hWaveIn
    Print "Error "; error; " in waveInStart"
    Exit Sub
End If

Print "Recording"
While (wh.dwFlags And WHDR_DONE) <> WHDR_DONE
    DoEvents
Wend
Print "Finished"

error = waveInUnprepareHeader(hWaveIn, wh, Len(wh))
If error <> 0 Then
    waveInClose hWaveIn
    Print "Error "; error; "in waveInUnprepareHeader"
    Exit Sub
End If

waveInClose hWaveIn
Print "Recorded data successfully"

0
 

Author Comment

by:pertex
ID: 1406048
Thanks a lot! I will check it out
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now