Solved

WIN 95 MMSYSTEM.dll function calls

Posted on 1997-09-07
4
237 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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

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…
What my article will show is if you ever had to do processing to a listbox without being able to just select all the items in it. My software Visual Studio 2008 crystal report v11 My issue was I wanted to add crystal report to a form and show…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

777 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