Visual Studio 2019
C#
dotPeek - for reverse engineering simple DMR plugin (as VS project)
Show code
Player.cs
namespace SDRSharp.DMR
{
public class Player : IDisposable
{
...
public int IqBufferSize { get; set; }
public uint dmrCode { get; set; } // add this line
...
Simple DMR plugin combines voice data from both timeslots into single channel, maybe playing from 0 to 287 or from 288 to 576 plays either ts.
private unsafe void PlayerThread()
{
this._needAudioConfigure = true;
while (this._playerEnabled)
{
if (this._iqStream.Length < 576 || this._audioSampleRate <= 0.0)
{
Thread.Sleep(20);
}
else
{
if (this._needAudioConfigure)
{
Player.Reset(this._mdmInstance);
this._scrambler.Init((uint) this._mdmInstance);
this._maxAudioBufferSize = (int) this._audioSampleRate;
this._resamplerAudio = new Resampler(8000.0, this._audioSampleRate, 160, 0.45);
this._needAudioConfigure = false;
}
this._iqStream.Read(this._modemInBufferPtr, 576);
this._scrambler.MpyScrm_p((float*) this._modemInBufferPtr, 1152);
int inputLength = Player.Process(this._mdmInstance, this._modemOutBufferPtr, (float*) this._modemInBufferPtr);
this.IsDigit = inputLength >= 0;
this.dmrCode = Player.GetCode(this._mdmInstance); // add this
if (inputLength > 0)
{
int count = this._resamplerAudio.Process(this._modemOutBufferPtr, this._resampledAudioBufferPtr, inputLength);
if (this._audioStream.Length + count < this._maxAudioBufferSize)
this._audioStream.Write(this._resampledAudioBufferPtr, count);
else
++this.LostBuffers;
}
}
}
}
DMRPanel.cs
...
private void DisplayTimer_Tick(object sender, EventArgs e)
{
if (this._player == null)
return;
this.isDpmrLabel.Visible = this._player.IsDigit;
// add this
if (this.isDpmrLabel.Visible)
{
isDpmrLabel.Text = "DMR " + this._player.dmrCode.ToString();
}
this.voiceLabel.Visible = this._player.IsVoice;
this.bufferLabel.Text = string.Format("Buffer: use {0:f1}% lost {1:f0}", (object) this._player.IqBufferSize, (object) this._player.LostBuffers);
}
Kommentit
Tämän blogin kommentit tarkistetaan ennen julkaisua.