Thanks for the reply radio42,
Sorry, I should have provided a little more information. That is how I originally created the stream, recorded it from input to a local byte array, then stopped recording. I'm happy if the functionality is that the waveform is generated after the stream stops recording, based on what was just recorded.
I have made some more progress in the meantime however. I now have no blatant errors, however when I generate a bitmap from my waveform it looks empty. It is the right length, and I can easily get a progress indicator moving across it as I play the stream back, however I don't see any peaks.
Now after my recording has been stored in memory, I create a new decoded stream and try to pass that to the RenderStart method of a WaveForm object.
Bass.BASS_ChannelStop(_streamA);
myStreamProc = new STREAMPROC(myStreaming);
_bytesread = 0;
_streamWave = Bass.BASS_StreamCreate(44100, 2, BASSStream.BASS_STREAM_DECODE, myStreamProc, 0);
wfp = new WAVEFORMPROC(myWaveFormProc);
Wave1 = new WaveForm(null, wfp, this);
GetWaveForm(_streamWave, Wave1);
My STREAMPROC just feeds the PCM data in from a byte array in memory, I know it works because I can use it to play back the stream if I remove the DECODE flag and call BASS_ChannelPlay on it.
private int myStreaming(int handle, IntPtr buffer, int length, int user)
{
// don't read past the end of the recorded data
int bytesToRead = Math.Min(length, _byteswritten - _bytesread);
Marshal.Copy(_recbuffer, _bytesread, buffer, bytesToRead);
if (length > _byteswritten - _bytesread)
bytesToRead |= (int)BASSStreamProc.BASS_STREAMPROC_END; // set indicator flag
_bytesread += bytesToRead;
return bytesToRead;
}
And finally the code I'm using the generate the WaveForm data:
private void GetWaveForm(int stream, WaveForm WF)
{
// render a wave form
//WF = new WaveForm(null, new WAVEFORMPROC(myWaveFormProc), this);
WF.FrameResolution = 0.01f; // 10ms are nice
WF.CallbackFrequency = 200; // every 30 seconds rendered (3000*10ms=30sec)
WF.ColorBackground = Color.WhiteSmoke;
WF.ColorLeft = Color.Gainsboro;
WF.ColorLeftEnvelope = Color.Gray;
WF.ColorRight = Color.LightGray;
WF.ColorRightEnvelope = Color.DimGray;
WF.ColorMarker = Color.DarkBlue;
WF.DrawWaveForm = WaveForm.WAVEFORMDRAWTYPE.Stereo;
WF.DrawMarker = WaveForm.MARKERDRAWTYPE.Line | WaveForm.MARKERDRAWTYPE.Name | WaveForm.MARKERDRAWTYPE.NamePositionAlternate;
WF.MarkerLength = 0.75f;
if (WF.RenderStart(stream, false))
{
Console.WriteLine("begin waveform rendering...");
}
else
{
MessageBox.Show(this, "Error: " + Enum.GetName(typeof(BASSErrorCode), Bass.BASS_ErrorGetCode()));
}
}
private void myWaveFormProc(int framesDone, int framesTotal, TimeSpan elapsedTime, bool finished)
{
if (finished)
{
Console.WriteLine("Finished rendering WaveForm in {0}s.", elapsedTime);
// only actually render the waveform on the screen when done
DrawWaves();
}
Console.Write(".");
}
private void DrawWaves()
{
if (Wave1 != null)
this.picWave1.BackgroundImage = Wave1.CreateBitmap(this.picWave1.Width, this.picWave1.Height, -1, -1, true);
}
Do you have any idea why I would be getting through it all error free, even getting reports in stdout saying things like waveform generated in 2.3456 seconds, yet my waveform image comes out empty? The issue is not with the DrawWaves() method - i.e. the bitmap is definitely being created, it is just a very boring bitmap with two horizontal grey lines representing the left and right channels.
Thanks!