I have this method that records audio in C#:
public Task StartNewRecording()
{
_name = DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss");
_name += " - " + Guid.NewGuid().ToString()[..4];
_name += ".wav";
var path = Path.Combine(_mainPath, _name);
_writer = new WaveFileWriter(new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read),
new WaveFormat());
Bass.RecordInit();
_recordingHandle = Bass.RecordStart(44100, 2, BassFlags.RecordPause, RecordingCallback);
Bass.ChannelPlay(_recordingHandle, true);
_startTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
return Task.CompletedTask;
}
The recording works in development mode but when I publish it for MacOS and Windows/Microsoft, their is problem while recording. To be specific, on the MacOS, I am receiving the error Device which means illegal device number.
The error is being thrown on the line 11. You can see the code Bass.RecordInit();
. This function returns a false value. If it is a false value, it means there was an error and while trying to check the error by adjusting that part of the code like the below:
var isSuccess = Bass.RecordInit();
if (!isSuccess)
{
throw new Exception(Bass.LastError.ToString());
}
This code is throwing the device error after being published for MacOS. I am confused because, it works perfectly fine on development mode and after publishing, the error suddenly appears.
I appreciate any kind of help. Thanks in advance!
i run the function Bass.RecordInit()
but it is returning false and upon checking the error it was a **device **error. I expect the function to return true on publish mode and get rid of the error.