To record a sound with Windows 10 on Xojo, first make a global property called:
Dim S as String = "SoundName"
Create a new file folder called c:\test\
The first instruction starts a new session to be recorded and the second instruction records the physical input from the microphone.
In the action event of the first pushbutton add:
[code]Declare Function mciSendString lib “winmm.dll” Alias “mciSendStringA” (lpstrCommand as Cstring, _
lpstrReturnString as CString, uReturnLength as Integer, hwndCallback as Integer) as Integer
//Dim S as String = “SoundName” 'global property
Call mciSendString(“open new type waveaudio alias RecFile”, s, 1024, 0)
Call mciSendString(“record RecFile”, s, 1024, 0)[/code]
Two instructions are sent again and the first instruction saves the recorded sound in c:\test\SoundName.wav file and path. The second instruction closes the recording session.
In the action event of the second pushbutton add:
[code]Declare Function mciSendString lib “winmm.dll” Alias “mciSendStringA” (lpstrCommand as Cstring, _
lpstrReturnString as CString, uReturnLength as Integer, hwndCallback as Integer) as Integer
//Dim S as String = “SoundName” 'global property
Call mciSendString(“save RecFile c:\test”+s+".wav", s, 1024, 0)
Call mciSendString(“close recsound”, s, 1024, 0)[/code]
To play the recorded sound, add the following to a third pushbutton action event:
Dim f as FolderItem = GetFolderItem("c:\\test\"+s+".wav")
If f <> Nil Then
Dim MySound as Sound = f.OpenAsSound
If MySound <> Nil Then
MySound.Play
Else
//Check f.LastErrorCode
End If
Else
//UserCancelled
End If
Edit: P.S. You may want to change this question from the General category to Windows.