Solved

WIN 95 MMSYSTEM.dll function calls

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
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…

730 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