Skip to content

Commit

Permalink
auto re-sample initial
Browse files Browse the repository at this point in the history
  • Loading branch information
Dustify committed Jan 29, 2024
1 parent df10da4 commit fa5ff33
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 22 deletions.
4 changes: 3 additions & 1 deletion SdrsDecoder.Cli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ static void Main(string[] args)
samples.Add(s);
}

var baud = 1200;

//var sr = file.WaveFormat.SampleRate;

//var i = 256;
Expand Down Expand Up @@ -87,7 +89,7 @@ static void Main(string[] args)
//}

var chain = new PocsagChain(
1200,
baud,
file.WaveFormat.SampleRate,
(message) =>
{
Expand Down
21 changes: 10 additions & 11 deletions SdrsDecoder/Flex/FlexChain.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using SdrsDecoder.Support;
using System;
using System.Collections.Generic;
using System.Numerics;

namespace SdrsDecoder.Flex
{
Expand All @@ -20,21 +21,19 @@ public FlexChain(float baud, float sampleRate, Action<MessageBase> messageReceiv
{
this.baud = baud;


var targetRate = (int)this.baud * 10;
var gcd = (int)BigInteger.GreatestCommonDivisor((BigInteger)sampleRate, (BigInteger)targetRate);

var i = 1;
var d = 1;
// TODO: refactor this stuff

if (baud == 1600)
{
i = 32;
d = 75;
}
int i = targetRate / gcd;
int d = (int)sampleRate / gcd;

if (baud == 3200)
// if I gets too big then filtering / performance becomes an issue
if (i > 100)
{
i = 64;
d = 75;
i = 1;
d = 1;
}

var isr = sampleRate * i;
Expand Down
20 changes: 10 additions & 10 deletions SdrsDecoder/Pocsag/PocsagChain.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using SdrsDecoder.Support;
using System;
using System.Numerics;

namespace SdrsDecoder.Pocsag
{
Expand All @@ -20,19 +21,18 @@ public PocsagChain(float baud, float sampleRate, Action<MessageBase> messageRece
{
this.baud = baud;

var i = 1;
var d = 1;
// TODO: refactor this and stuff in flexchain
var targetRate = (int)this.baud * 10;
var gcd = (int)BigInteger.GreatestCommonDivisor((BigInteger)sampleRate, (BigInteger)targetRate);

if (baud == 1200)
{
i = 8;
d = 25;
}
int i = targetRate / gcd;
int d = (int)sampleRate / gcd;

if (baud == 2400)
// if I gets too big then filtering / performance becomes an issue
if (i > 100)
{
i = 16;
d = 25;
i = 1;
d = 1;
}

var isr = sampleRate * i;
Expand Down

0 comments on commit fa5ff33

Please sign in to comment.