mirror of
https://github.com/cnlohr/lolra.git
synced 2026-06-17 00:09:31 +00:00
Working with arbitrary goertzel's
This commit is contained in:
@@ -84,6 +84,7 @@ int g_volume_pwm = 127; // 0 - 127 (100%) (but you can go over 100)
|
|||||||
#if 0
|
#if 0
|
||||||
int g_pwm_period = (30-1);
|
int g_pwm_period = (30-1);
|
||||||
int g_goertzel_buffer = (752);
|
int g_goertzel_buffer = (752);
|
||||||
|
int g_exactcompute = (0);
|
||||||
int32_t g_goertzel_omega_per_sample = 2485087396; // 0.368351 of whole per step / 27.031915MHz
|
int32_t g_goertzel_omega_per_sample = 2485087396; // 0.368351 of whole per step / 27.031915MHz
|
||||||
int32_t g_goertzel_coefficient = -1453756170;
|
int32_t g_goertzel_coefficient = -1453756170;
|
||||||
int32_t g_goertzel_coefficient_s = 1580594514;
|
int32_t g_goertzel_coefficient_s = 1580594514;
|
||||||
@@ -92,6 +93,7 @@ int32_t g_goertzel_coefficient_s = 1580594514;
|
|||||||
#if 1
|
#if 1
|
||||||
int g_pwm_period = (30-1);
|
int g_pwm_period = (30-1);
|
||||||
int g_goertzel_buffer = (180);
|
int g_goertzel_buffer = (180);
|
||||||
|
int g_exactcompute = (0);
|
||||||
int32_t g_goertzel_omega_per_sample = 5509657063; // 0.816667 of whole per step / 0.880000MHz
|
int32_t g_goertzel_omega_per_sample = 5509657063; // 0.816667 of whole per step / 0.880000MHz
|
||||||
int32_t g_goertzel_coefficient = 873460290;
|
int32_t g_goertzel_coefficient = 873460290;
|
||||||
int32_t g_goertzel_coefficient_s = -1961823932;
|
int32_t g_goertzel_coefficient_s = -1961823932;
|
||||||
@@ -100,6 +102,7 @@ int32_t g_goertzel_coefficient_s = -1961823932;
|
|||||||
#if 0
|
#if 0
|
||||||
int g_pwm_period = (31-1);
|
int g_pwm_period = (31-1);
|
||||||
int g_goertzel_buffer = (412);
|
int g_goertzel_buffer = (412);
|
||||||
|
int g_exactcompute = (0);
|
||||||
const int32_t g_goertzel_omega_per_sample = 1670254667; // 0.247573 of whole per step / 1.150016MHz
|
const int32_t g_goertzel_omega_per_sample = 1670254667; // 0.247573 of whole per step / 1.150016MHz
|
||||||
const int32_t g_goertzel_coefficient = 32748822;
|
const int32_t g_goertzel_coefficient = 32748822;
|
||||||
const int32_t g_goertzel_coefficient_s = 2147233926;
|
const int32_t g_goertzel_coefficient_s = 2147233926;
|
||||||
@@ -108,6 +111,7 @@ const int32_t g_goertzel_coefficient_s = 2147233926;
|
|||||||
#if 0
|
#if 0
|
||||||
int g_pwm_period = (30-1);
|
int g_pwm_period = (30-1);
|
||||||
int g_goertzel_buffer = (576);
|
int g_goertzel_buffer = (576);
|
||||||
|
int g_exactcompute = (0);
|
||||||
int32_t g_goertzel_omega_per_sample = 1264972285; // 0.187500 of whole per step / 90.300000MHz
|
int32_t g_goertzel_omega_per_sample = 1264972285; // 0.187500 of whole per step / 90.300000MHz
|
||||||
int32_t g_goertzel_coefficient = 821806413;
|
int32_t g_goertzel_coefficient = 821806413;
|
||||||
int32_t g_goertzel_coefficient_s = 1984016189;
|
int32_t g_goertzel_coefficient_s = 1984016189;
|
||||||
@@ -116,6 +120,7 @@ int32_t g_goertzel_coefficient_s = 1984016189;
|
|||||||
#if 0
|
#if 0
|
||||||
int g_pwm_period = (30-1);
|
int g_pwm_period = (30-1);
|
||||||
int g_goertzel_buffer = (320);
|
int g_goertzel_buffer = (320);
|
||||||
|
int g_exactcompute = (0);
|
||||||
const int32_t g_goertzel_omega_per_sample = 990894956; // 0.146875 of whole per step / 101.505000MHz
|
const int32_t g_goertzel_omega_per_sample = 990894956; // 0.146875 of whole per step / 101.505000MHz
|
||||||
const int32_t g_goertzel_coefficient = 1296126516;
|
const int32_t g_goertzel_coefficient = 1296126516;
|
||||||
const int32_t g_goertzel_coefficient_s = 1712233066;
|
const int32_t g_goertzel_coefficient_s = 1712233066;
|
||||||
@@ -124,6 +129,7 @@ const int32_t g_goertzel_coefficient_s = 1712233066;
|
|||||||
#if 0
|
#if 0
|
||||||
int g_pwm_period = (30-1);
|
int g_pwm_period = (30-1);
|
||||||
int g_goertzel_buffer = (384);
|
int g_goertzel_buffer = (384);
|
||||||
|
int g_exactcompute = (0);
|
||||||
const int32_t g_goertzel_omega_per_sample = 4251712402; // 0.630208 of whole per step / 27.025000MHz
|
const int32_t g_goertzel_omega_per_sample = 4251712402; // 0.630208 of whole per step / 27.025000MHz
|
||||||
const int32_t g_goertzel_coefficient = -1468003291;
|
const int32_t g_goertzel_coefficient = -1468003291;
|
||||||
const int32_t g_goertzel_coefficient_s = -1567371161;
|
const int32_t g_goertzel_coefficient_s = -1567371161;
|
||||||
@@ -132,6 +138,7 @@ const int32_t g_goertzel_coefficient_s = -1567371161;
|
|||||||
#if 0
|
#if 0
|
||||||
int g_pwm_period = (30-1);
|
int g_pwm_period = (30-1);
|
||||||
int g_goertzel_buffer = (336);
|
int g_goertzel_buffer = (336);
|
||||||
|
int g_exactcompute = (0);
|
||||||
const int32_t g_goertzel_omega_per_sample = 1827182189; // 0.270833 of whole per step / 89.900000MHz
|
const int32_t g_goertzel_omega_per_sample = 1827182189; // 0.270833 of whole per step / 89.900000MHz
|
||||||
const int32_t g_goertzel_coefficient = -280302863;
|
const int32_t g_goertzel_coefficient = -280302863;
|
||||||
const int32_t g_goertzel_coefficient_s = 2129111628;
|
const int32_t g_goertzel_coefficient_s = 2129111628;
|
||||||
@@ -273,6 +280,7 @@ int32_t g_goertzelp_store, g_goertzelp2_store;
|
|||||||
int32_t g_laststart = 0;
|
int32_t g_laststart = 0;
|
||||||
int32_t g_lastper;
|
int32_t g_lastper;
|
||||||
int32_t g_lastlen;
|
int32_t g_lastlen;
|
||||||
|
uint32_t g_accumulate_over_window;
|
||||||
|
|
||||||
void DMA1_Channel1_IRQHandler( void ) __attribute__((interrupt));
|
void DMA1_Channel1_IRQHandler( void ) __attribute__((interrupt));
|
||||||
void DMA1_Channel1_IRQHandler( void )
|
void DMA1_Channel1_IRQHandler( void )
|
||||||
@@ -290,6 +298,7 @@ void DMA1_Channel1_IRQHandler( void )
|
|||||||
int32_t goertzelp2 = g_goertzelp2;
|
int32_t goertzelp2 = g_goertzelp2;
|
||||||
int32_t goertzelp = g_goertzelp;
|
int32_t goertzelp = g_goertzelp;
|
||||||
int32_t goertzel = g_goertzel;
|
int32_t goertzel = g_goertzel;
|
||||||
|
int32_t accumulate_over_window = g_accumulate_over_window;
|
||||||
|
|
||||||
uint32_t goertzel_samples = g_goertzel_samples;
|
uint32_t goertzel_samples = g_goertzel_samples;
|
||||||
// Backup flags.
|
// Backup flags.
|
||||||
@@ -309,7 +318,7 @@ void DMA1_Channel1_IRQHandler( void )
|
|||||||
|
|
||||||
#define INFADC 2
|
#define INFADC 2
|
||||||
// Add a tiny bias to the ADC to help keep goertz in range.
|
// Add a tiny bias to the ADC to help keep goertz in range.
|
||||||
const int adc_offset = (-2048) << INFADC;
|
static int adc_offset = (-2048) << INFADC;
|
||||||
|
|
||||||
while( adc_tail != adc_buffer_end )
|
while( adc_tail != adc_buffer_end )
|
||||||
{
|
{
|
||||||
@@ -325,13 +334,14 @@ void DMA1_Channel1_IRQHandler( void )
|
|||||||
lhu %[adcin]," XSTR(idx) "(%[adc_tail]) \n\
|
lhu %[adcin]," XSTR(idx) "(%[adc_tail]) \n\
|
||||||
slli %[adcin],%[adcin],%[iadc] /*INFADC = 2*/ \n\
|
slli %[adcin],%[adcin],%[iadc] /*INFADC = 2*/ \n\
|
||||||
add %[adcin],%[adcin],%[adcoffset] /*adcin += adcoffset*/ \n\
|
add %[adcin],%[adcin],%[adcoffset] /*adcin += adcoffset*/ \n\
|
||||||
|
add %[accumulate_over_window], %[adcin], %[accumulate_over_window]\n \
|
||||||
addi %[goertzelp2],%[goertzelp],0 /*goertzelp2 = goertzelp*/ \n\
|
addi %[goertzelp2],%[goertzelp],0 /*goertzelp2 = goertzelp*/ \n\
|
||||||
addi %[goertzelp], %[goertzel],0 /*goertzelp = goertzel*/ \n\
|
addi %[goertzelp], %[goertzel],0 /*goertzelp = goertzel*/ \n\
|
||||||
slli %[goertzel], %[goertzelp], 2 /*prescaling up goertzelp*/\n\
|
slli %[goertzel], %[goertzelp], 2 /*prescaling up goertzelp*/\n\
|
||||||
mulh %[goertzel], %[goertzel_coefficient], %[goertzel]\n\
|
mulh %[goertzel], %[goertzel_coefficient], %[goertzel]\n\
|
||||||
sub %[adcin],%[adcin],%[goertzelp2] /*adcin -= goertzelp2*/ \n\
|
sub %[adcin],%[adcin],%[goertzelp2] /*adcin -= goertzelp2*/ \n\
|
||||||
add %[goertzel], %[goertzel], %[adcin] /* mulh = signed * signed + adc */ \n"\
|
add %[goertzel], %[goertzel], %[adcin] /* mulh = signed * signed + adc */ \n"\
|
||||||
: [goertzel]"+r"(goertzel), [goertzelp]"+r"(goertzelp), [goertzelp2]"+r"(goertzelp2), [adcin]"+r"(t) : \
|
: [goertzel]"+r"(goertzel), [goertzelp]"+r"(goertzelp), [goertzelp2]"+r"(goertzelp2), [adcin]"+r"(t), [accumulate_over_window]"+r"(accumulate_over_window) : \
|
||||||
[adc_tail]"r"(adc_tail), [adcoffset]"r"(adc_offset), [goertzel_coefficient]"r"(goertzel_coefficient), [iadc]"i"(INFADC) );
|
[adc_tail]"r"(adc_tail), [adcoffset]"r"(adc_offset), [goertzel_coefficient]"r"(goertzel_coefficient), [iadc]"i"(INFADC) );
|
||||||
|
|
||||||
GOERTZELLOOP(0);
|
GOERTZELLOOP(0);
|
||||||
@@ -369,7 +379,7 @@ void DMA1_Channel1_IRQHandler( void )
|
|||||||
funDigitalWrite( PROFILING_PIN, 0 );
|
funDigitalWrite( PROFILING_PIN, 0 );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
g_goertzelp_store = goertzel - (g_goertzel_omega_per_sample>>(29-16));
|
g_goertzelp_store = goertzel;
|
||||||
g_goertzelp2_store = goertzelp;
|
g_goertzelp2_store = goertzelp;
|
||||||
|
|
||||||
int32_t zp = g_goertzelp_store;
|
int32_t zp = g_goertzelp_store;
|
||||||
@@ -391,20 +401,24 @@ void DMA1_Channel1_IRQHandler( void )
|
|||||||
intensity = 1;
|
intensity = 1;
|
||||||
intensity = (intensity + s/intensity)/2;
|
intensity = (intensity + s/intensity)/2;
|
||||||
intensity = (intensity + s/intensity)/2;
|
intensity = (intensity + s/intensity)/2;
|
||||||
intensity_average = intensity_average - (intensity_average>>12) + (intensity>>2);
|
intensity_average = intensity_average - (intensity_average>>12) + (intensity>>6);
|
||||||
|
|
||||||
|
|
||||||
#ifdef PWM_OUTPUT
|
#ifdef PWM_OUTPUT
|
||||||
intensity = intensity * g_volume_pwm * g_pwm_period / (intensity_average>>(10-8));
|
intensity = intensity * g_volume_pwm * g_pwm_period / (intensity_average>>(10-12));
|
||||||
if( intensity >= g_pwm_period-1 ) intensity = g_pwm_period-2;
|
if( intensity >= g_pwm_period-1 ) intensity = g_pwm_period-2;
|
||||||
if( intensity < 1 ) intensity = 1;
|
if( intensity < 1 ) intensity = 1;
|
||||||
TIM1->CH2CVR = intensity; // Actual duty cycle (Off to begin with)
|
TIM1->CH2CVR = intensity; // Actual duty cycle (Off to begin with)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
g_goertzel_outs++;
|
g_goertzel_outs++;
|
||||||
goertzel = g_goertzel_omega_per_sample>>(29-16);
|
goertzel = 0;
|
||||||
goertzelp = 0;
|
goertzelp = 0;
|
||||||
goertzel_samples = 0;
|
goertzel_samples = 0;
|
||||||
|
|
||||||
|
// Try to improve bias.
|
||||||
|
adc_offset -= accumulate_over_window / g_goertzel_buffer;
|
||||||
|
accumulate_over_window = 0;
|
||||||
|
|
||||||
#ifdef PROFILING_PIN
|
#ifdef PROFILING_PIN
|
||||||
funDigitalWrite( PROFILING_PIN, 1 );
|
funDigitalWrite( PROFILING_PIN, 1 );
|
||||||
#endif
|
#endif
|
||||||
@@ -419,6 +433,7 @@ void DMA1_Channel1_IRQHandler( void )
|
|||||||
g_goertzelp = goertzelp;
|
g_goertzelp = goertzelp;
|
||||||
g_goertzel = goertzel;
|
g_goertzel = goertzel;
|
||||||
g_goertzel_samples = goertzel_samples;
|
g_goertzel_samples = goertzel_samples;
|
||||||
|
g_accumulate_over_window = accumulate_over_window;
|
||||||
|
|
||||||
#ifdef PROFILING_PIN
|
#ifdef PROFILING_PIN
|
||||||
funDigitalWrite( PROFILING_PIN, 0 ); // For profiling
|
funDigitalWrite( PROFILING_PIN, 0 ); // For profiling
|
||||||
@@ -467,8 +482,8 @@ void InnerLoop()
|
|||||||
int16_t rr = combiq & 0xffff;
|
int16_t rr = combiq & 0xffff;
|
||||||
int16_t ri = combiq >> 16;
|
int16_t ri = combiq >> 16;
|
||||||
|
|
||||||
rr = rr * 512 / (intensity_average>>4);
|
rr = rr * 512 / (intensity_average);
|
||||||
ri = ri * 512 / (intensity_average>>4);
|
ri = ri * 512 / (intensity_average);
|
||||||
|
|
||||||
rr += 64;
|
rr += 64;
|
||||||
ri += 64;
|
ri += 64;
|
||||||
@@ -647,7 +662,7 @@ int HandleHidUserGetReportSetup( struct _USBState * ctx, tusb_control_request_t
|
|||||||
int samps_to_send = (qibaselogs_head - last_baselog + LOG_GOERTZEL_LIST * 2 - 1) & (LOG_GOERTZEL_LIST-1);
|
int samps_to_send = (qibaselogs_head - last_baselog + LOG_GOERTZEL_LIST * 2 - 1) & (LOG_GOERTZEL_LIST-1);
|
||||||
if( samps_to_send > 120 ) samps_to_send = 120;
|
if( samps_to_send > 120 ) samps_to_send = 120;
|
||||||
|
|
||||||
((uint32_t*)scratchpad)[0] = (intensity_average<<8) | samps_to_send;
|
((uint32_t*)scratchpad)[0] = (intensity_average<<12) | samps_to_send;
|
||||||
((uint32_t*)scratchpad)[1] = (g_lastper<<16) | g_lastlen;
|
((uint32_t*)scratchpad)[1] = (g_lastper<<16) | g_lastlen;
|
||||||
((uint32_t*)scratchpad)[2] = (0<<16) | (((g_pwm_period+1)*g_goertzel_buffer)); //LSW = 144MHz / X
|
((uint32_t*)scratchpad)[2] = (0<<16) | (((g_pwm_period+1)*g_goertzel_buffer)); //LSW = 144MHz / X
|
||||||
|
|
||||||
@@ -695,6 +710,7 @@ void HandleHidUserReportOutComplete( struct _USBState * ctx )
|
|||||||
if( numconfigs > 2) g_goertzel_omega_per_sample = configs[4]; // 0.816667 of whole per step / 0.880000MHz
|
if( numconfigs > 2) g_goertzel_omega_per_sample = configs[4]; // 0.816667 of whole per step / 0.880000MHz
|
||||||
if( numconfigs > 3) g_goertzel_coefficient = configs[5];
|
if( numconfigs > 3) g_goertzel_coefficient = configs[5];
|
||||||
if( numconfigs > 4) g_goertzel_coefficient_s = configs[6];
|
if( numconfigs > 4) g_goertzel_coefficient_s = configs[6];
|
||||||
|
if( numconfigs > 5) g_exactcompute = configs[7];
|
||||||
|
|
||||||
// Need to reset so we don't blast by.
|
// Need to reset so we don't blast by.
|
||||||
g_goertzel_samples = 0;
|
g_goertzel_samples = 0;
|
||||||
|
|||||||
Binary file not shown.
+90
-14
@@ -11,18 +11,18 @@ body { background-color: Canvas; color: CanvasText; }
|
|||||||
<SCRIPT src=webhidcontrol.js></SCRIPT>
|
<SCRIPT src=webhidcontrol.js></SCRIPT>
|
||||||
|
|
||||||
<SCRIPT>
|
<SCRIPT>
|
||||||
function DrawSpan( colspan, freq, target, docolor, extrastr = "" )
|
function DrawSpan( rowspan, colspan, freq, target, docolor, extrastr = "" )
|
||||||
{
|
{
|
||||||
var fdist = Math.abs( freq - target );
|
var fdist = Math.abs( freq - target );
|
||||||
fdist = Math.pow( fdist, 0.5 ) * 500;
|
fdist = Math.pow( fdist, 0.5 ) * 500;
|
||||||
// if( fdist > 255 ) fdist = 255;
|
// if( fdist > 255 ) fdist = 255;
|
||||||
let ret = "<TD COLSPAN=" + colspan + ' ';
|
let ret = "<TD COLSPAN=" + colspan + ' ROWSPAN' + rowspan + ' ';
|
||||||
if( docolor ) ret += 'STYLE="color:black;background-color:rgb(' + fdist + ',' + (511-fdist) + ',0)";';
|
if( docolor ) ret += 'STYLE="color:black;background-color:rgb(' + fdist + ',' + (511-fdist) + ',0)";';
|
||||||
ret += '>' + extrastr + freq.toFixed(6) + "</TD>";
|
ret += '>' + extrastr + freq.toFixed(6) + "</TD>";
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
function Goertz( n, mhz, fr, brf )
|
function Goertz( n, mhz, fr, brf, exact_compute )
|
||||||
{
|
{
|
||||||
let omega = fr * 3.1415926535*2.0;
|
let omega = fr * 3.1415926535*2.0;
|
||||||
var textarea = document.getElementById("goertzeloutput");
|
var textarea = document.getElementById("goertzeloutput");
|
||||||
@@ -30,8 +30,10 @@ function Goertz( n, mhz, fr, brf )
|
|||||||
var g_goertzel_omega_per_sample = Math.round( ( omega*2*(1<<29)) );
|
var g_goertzel_omega_per_sample = Math.round( ( omega*2*(1<<29)) );
|
||||||
var g_goertzel_coefficient = Math.round( (2 * Math.cos( omega ) * (1<<30)) );
|
var g_goertzel_coefficient = Math.round( (2 * Math.cos( omega ) * (1<<30)) );
|
||||||
var g_goertzel_coefficient_s = Math.round( (2 * Math.sin( omega ) * (1<<30)) );
|
var g_goertzel_coefficient_s = Math.round( (2 * Math.sin( omega ) * (1<<30)) );
|
||||||
|
var g_exactcompute = exact_compute;
|
||||||
textarea.value =
|
textarea.value =
|
||||||
"int g_pwm_period = ("+n+"-1);\n" +
|
"int g_pwm_period = ("+n+"-1);\n" +
|
||||||
|
"int g_exactcompute = ("+exact_compute+");\n" +
|
||||||
"int g_goertzel_buffer = ("+brf+");\n" +
|
"int g_goertzel_buffer = ("+brf+");\n" +
|
||||||
"int32_t g_goertzel_omega_per_sample = " + g_goertzel_coefficient.toFixed(0) + "; // " + ( omega / (3.1415926535*2.0)).toFixed(6) + " of whole per step / " + mhz.toFixed(6) + "MHz\n" +
|
"int32_t g_goertzel_omega_per_sample = " + g_goertzel_coefficient.toFixed(0) + "; // " + ( omega / (3.1415926535*2.0)).toFixed(6) + " of whole per step / " + mhz.toFixed(6) + "MHz\n" +
|
||||||
"int32_t g_goertzel_coefficient = " + g_goertzel_coefficient.toFixed(0) + ";\n" +
|
"int32_t g_goertzel_coefficient = " + g_goertzel_coefficient.toFixed(0) + ";\n" +
|
||||||
@@ -43,7 +45,7 @@ function Goertz( n, mhz, fr, brf )
|
|||||||
// Copy the highlighted text
|
// Copy the highlighted text
|
||||||
document.execCommand("copy");
|
document.execCommand("copy");
|
||||||
|
|
||||||
updateWebHidDeviceWithParameters( [ (n-1)|0, brf|0, g_goertzel_omega_per_sample|0, g_goertzel_coefficient|0, g_goertzel_coefficient_s|0 ] );
|
updateWebHidDeviceWithParameters( [ (n-1)|0, brf|0, g_goertzel_omega_per_sample|0, g_goertzel_coefficient|0, g_goertzel_coefficient_s|0, exact_compute|0 ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
function computeTable()
|
function computeTable()
|
||||||
@@ -51,6 +53,8 @@ function computeTable()
|
|||||||
let xtal = Number(document.getElementById("crystalmhz").value );
|
let xtal = Number(document.getElementById("crystalmhz").value );
|
||||||
let target = Number(document.getElementById("targetmhz").value );
|
let target = Number(document.getElementById("targetmhz").value );
|
||||||
let quadrature = document.getElementById("QUADRATURE").checked;
|
let quadrature = document.getElementById("QUADRATURE").checked;
|
||||||
|
let goertzels = document.getElementById("GOERTZELS").checked;
|
||||||
|
let goertzel2 = document.getElementById("GOERTZEL2").checked;
|
||||||
let quanta = Math.round(Number(document.getElementById("quanta").value));
|
let quanta = Math.round(Number(document.getElementById("quanta").value));
|
||||||
let quantasearch = Math.round(Number(document.getElementById("quantasearch").value));
|
let quantasearch = Math.round(Number(document.getElementById("quantasearch").value));
|
||||||
|
|
||||||
@@ -78,7 +82,7 @@ function computeTable()
|
|||||||
"<TR><TD>Differential Frequency</TD></TR>" +
|
"<TR><TD>Differential Frequency</TD></TR>" +
|
||||||
"</TABLE>";
|
"</TABLE>";
|
||||||
}
|
}
|
||||||
else
|
else if( goertzels )
|
||||||
{
|
{
|
||||||
contents +=
|
contents +=
|
||||||
"<TABLE BORDER=1>" +
|
"<TABLE BORDER=1>" +
|
||||||
@@ -90,6 +94,8 @@ function computeTable()
|
|||||||
"<P>Goertzel's mode is for the ch32v203</P>";
|
"<P>Goertzel's mode is for the ch32v203</P>";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( goertzels || quadrature )
|
||||||
|
{
|
||||||
contents += "<TABLE BORDER=1>";
|
contents += "<TABLE BORDER=1>";
|
||||||
contents += '<TR><TH>d\\h</div></TH>';
|
contents += '<TR><TH>d\\h</div></TH>';
|
||||||
for( let h = 0|min_harmonics; h <= max_harmonics; h++ )
|
for( let h = 0|min_harmonics; h <= max_harmonics; h++ )
|
||||||
@@ -150,35 +156,35 @@ function computeTable()
|
|||||||
if( quadrature )
|
if( quadrature )
|
||||||
{
|
{
|
||||||
if( mode == 0 )
|
if( mode == 0 )
|
||||||
contents += DrawSpan( 2, freq * h, target, false );
|
contents += DrawSpan( 1, 2, freq * h, target, false );
|
||||||
else if( mode == 1 )
|
else if( mode == 1 )
|
||||||
contents += DrawSpan( 2, freq * (h-.25), target, true );
|
contents += DrawSpan( 1, 2, freq * (h-.25), target, true );
|
||||||
else if( mode == 2 )
|
else if( mode == 2 )
|
||||||
contents += DrawSpan( 2, freq * (h+.25), target, true );
|
contents += DrawSpan( 1, 2, freq * (h+.25), target, true );
|
||||||
else if( mode == 3 )
|
else if( mode == 3 )
|
||||||
contents += DrawSpan( 2, freq * (h+0.5), target, true );
|
contents += DrawSpan( 1, 2, freq * (h+0.5), target, true );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( mode == 0 )
|
if( mode == 0 )
|
||||||
{
|
{
|
||||||
contents += "<TD COLSPAN=2>"
|
contents += "<TD COLSPAN=2>"
|
||||||
if( tgoertzelp == h ) contents += "<SPAN ONCLICK='Goertz(" + n + ", " + freq * (h+goertzelpoint) + ", " + (goertzelpoint) + ", " + quantaA + ")'>↑" + (goertzelpoint).toFixed(6) + "</SPAN>";
|
if( tgoertzelp == h ) contents += "<SPAN ONCLICK='Goertz(" + n + ", " + freq * (h+goertzelpoint) + ", " + (goertzelpoint) + ", " + quantaA + ", 0)'>↑" + (goertzelpoint).toFixed(6) + "</SPAN>";
|
||||||
contents += "</TD>";
|
contents += "</TD>";
|
||||||
}
|
}
|
||||||
else if( mode == 1 )
|
else if( mode == 1 )
|
||||||
{
|
{
|
||||||
contents += DrawSpan( 2, freq * (h+goertzelpoint), target, true );
|
contents += DrawSpan( 1, 2, freq * (h+goertzelpoint), target, true );
|
||||||
}
|
}
|
||||||
else if( mode == 2 )
|
else if( mode == 2 )
|
||||||
{
|
{
|
||||||
contents += "<TD COLSPAN=2>"
|
contents += "<TD COLSPAN=2>"
|
||||||
if( tgoertzelpi == h-1 ) contents += "<SPAN ONCLICK='Goertz(" + n + ", " + freq * (h-goertzelpointinv) + ", " + goertzelpointinv + ", " + quantaINV + ")'>↓" + goertzelpointinv.toFixed(6) + "</SPAN>";
|
if( tgoertzelpi == h-1 ) contents += "<SPAN ONCLICK='Goertz(" + n + ", " + freq * (h-goertzelpointinv) + ", " + goertzelpointinv + ", " + quantaINV + ", 0)'>↓" + goertzelpointinv.toFixed(6) + "</SPAN>";
|
||||||
contents += "</TD>";
|
contents += "</TD>";
|
||||||
}
|
}
|
||||||
else if( mode == 3 )
|
else if( mode == 3 )
|
||||||
{
|
{
|
||||||
contents += DrawSpan( 2, freq * (h-goertzelpointinv), target, true );
|
contents += DrawSpan( 1, 2, freq * (h-goertzelpointinv), target, true );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -186,6 +192,72 @@ function computeTable()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
contents += "</TABLE>";
|
contents += "</TABLE>";
|
||||||
|
}
|
||||||
|
else if( goertzel2 )
|
||||||
|
{
|
||||||
|
contents += "</TABLE><TEXTAREA ROWS=6 COLS=120 ID=goertzeloutput></TEXTAREA><BR>";
|
||||||
|
contents += "<TABLE BORDER=1>";
|
||||||
|
contents += '<TR><TH>d\\h</div></TH>';
|
||||||
|
for( let h = 0|min_harmonics; h <= max_harmonics+1; h++ )
|
||||||
|
{
|
||||||
|
contents += "<TH COLSPAN=1>" + h + "</TH>";
|
||||||
|
}
|
||||||
|
|
||||||
|
for( let n = 0|28; n <= 96; n++ )
|
||||||
|
{
|
||||||
|
let freq = ( xtal / n );
|
||||||
|
let goertzelpoint = 0;
|
||||||
|
let goertzelpointinv = 0;
|
||||||
|
let tgoertzelp = 0;
|
||||||
|
let tgoertzelpi = 0;
|
||||||
|
let quantaA = 0;
|
||||||
|
let quantaINV = 0;
|
||||||
|
|
||||||
|
for( let rid = 0|0; rid < 2|0; rid++ )
|
||||||
|
{
|
||||||
|
contents += "<TR>";
|
||||||
|
for( let h = -2|min_harmonics; h <= max_harmonics; h++ )
|
||||||
|
{
|
||||||
|
let tquanta = (quanta&0xffffc);
|
||||||
|
let base = freq * h;
|
||||||
|
let next = freq * (h+1);
|
||||||
|
|
||||||
|
let tgoertzelpoint = tquanta;
|
||||||
|
tgoertzelpoint = ( target - base ) / ( next - base );
|
||||||
|
tgoertzelpoint = ((tgoertzelpoint%1)+1)%1;
|
||||||
|
|
||||||
|
quantaA = tquanta;
|
||||||
|
tgoertzelp = h;
|
||||||
|
if( h == -2 )
|
||||||
|
{
|
||||||
|
if( rid == 0 )
|
||||||
|
{
|
||||||
|
contents += "<TD COLSPAN=1 ROWSPAN=2>"
|
||||||
|
contents += "<SPAN ONCLICK='Goertz(" + n + ", " + freq * (h+tgoertzelpoint) + ", " + (tgoertzelpoint) + ", " + quantaA + ", 1)'>↑" + n + "</SPAN>";
|
||||||
|
contents += "</TD>"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if( rid == 0 )
|
||||||
|
{
|
||||||
|
contents += DrawSpan( 1, 1, freq * (h+tgoertzelpoint), target, true );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
contents += DrawSpan( 1, 1, freq * (h-tgoertzelpoint), target, true );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
contents += "</TR>";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
contents += "</TABLE>";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
document.getElementById( "TABLE" ).innerHTML = contents;
|
document.getElementById( "TABLE" ).innerHTML = contents;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,7 +285,11 @@ function onLoad()
|
|||||||
<TR><TD>Target MHz</TD><TD><INPUT ID=targetmhz VALUE=27.019360></TD></TR>
|
<TR><TD>Target MHz</TD><TD><INPUT ID=targetmhz VALUE=27.019360></TD></TR>
|
||||||
<TR><TD>Quanta</TD><TD><INPUT ID=quanta VALUE=1024> (Goertzel's Only)</TD></TR>
|
<TR><TD>Quanta</TD><TD><INPUT ID=quanta VALUE=1024> (Goertzel's Only)</TD></TR>
|
||||||
<TR><TD>Quanta Search Range</TD><TD><INPUT ID=quantasearch VALUE=64> (Goertzel's Only)</TD></TR>
|
<TR><TD>Quanta Search Range</TD><TD><INPUT ID=quantasearch VALUE=64> (Goertzel's Only)</TD></TR>
|
||||||
<TR><TD>Table Type</TD><TD><INPUT TYPE=RADIO ID=QUADRATURE NAME=computetype checked>Quadrature</INPUT><INPUT TYPE=RADIO ID=GOERTZELS NAME=computetype>Goertzels</INPUT></TD></TR>
|
<TR><TD>Table Type</TD><TD>
|
||||||
|
<INPUT TYPE=RADIO ID=QUADRATURE NAME=computetype>Quadrature</INPUT>
|
||||||
|
<INPUT TYPE=RADIO ID=GOERTZELS NAME=computetype>Goertzels</INPUT>
|
||||||
|
<INPUT TYPE=RADIO ID=GOERTZEL2 NAME=computetype checked>Goertzel (unalign)</INPUT>
|
||||||
|
</TD></TR>
|
||||||
<TR><TD COLSPAN=2><INPUT TYPE=SUBMIT VALUE="Compute" ONCLICK="computeTable()"></TD></TR>
|
<TR><TD COLSPAN=2><INPUT TYPE=SUBMIT VALUE="Compute" ONCLICK="computeTable()"></TD></TR>
|
||||||
</TABLE>
|
</TABLE>
|
||||||
</TD>
|
</TD>
|
||||||
|
|||||||
+49
-52
@@ -5,6 +5,7 @@ let loopAbort = false;
|
|||||||
|
|
||||||
const IQHistoryLen = 4096;
|
const IQHistoryLen = 4096;
|
||||||
var IQHistoryArray = new Uint32Array(IQHistoryLen);
|
var IQHistoryArray = new Uint32Array(IQHistoryLen);
|
||||||
|
var MPHistoryArray = new Float32Array(IQHistoryLen*2);
|
||||||
var IQHistoryHead = 0|0;
|
var IQHistoryHead = 0|0;
|
||||||
var lastIntensity = 1.0;
|
var lastIntensity = 1.0;
|
||||||
var lastNumQ = 0;
|
var lastNumQ = 0;
|
||||||
@@ -66,7 +67,7 @@ var targetGain = 0.0;
|
|||||||
|
|
||||||
function UpdateButtonNames()
|
function UpdateButtonNames()
|
||||||
{
|
{
|
||||||
document.getElementById( "ToggleAudioButton" ).value = ( targetGain > 0.5 ) ? "Stop Audio" : "Start Audio";
|
document.getElementById( "ToggleAudioButton" ).value = ( targetGain > 0.0 ) ? "Stop Audio" : "Start Audio";
|
||||||
document.getElementById( "ToggleAudioModulationButton" ).value = ( targetModulation > 0.5 ) ? "FM" : "AM";
|
document.getElementById( "ToggleAudioModulationButton" ).value = ( targetModulation > 0.5 ) ? "FM" : "AM";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,8 +76,6 @@ async function toggleAudioModulation()
|
|||||||
if( playingAudioProcessor != null )
|
if( playingAudioProcessor != null )
|
||||||
{
|
{
|
||||||
var newVal = 1 - targetModulation;
|
var newVal = 1 - targetModulation;
|
||||||
let demodmodeParam = playingAudioProcessor.parameters.get("demodmode");
|
|
||||||
demodmodeParam.setValueAtTime( newVal, audioContext.currentTime);
|
|
||||||
targetModulation = newVal;
|
targetModulation = newVal;
|
||||||
}
|
}
|
||||||
UpdateButtonNames();
|
UpdateButtonNames();
|
||||||
@@ -91,8 +90,6 @@ async function toggleAudio()
|
|||||||
static get parameterDescriptors() {\
|
static get parameterDescriptors() {\
|
||||||
return [\
|
return [\
|
||||||
{ name: "gain", defaultValue: 0, },\
|
{ name: "gain", defaultValue: 0, },\
|
||||||
{ name: "demodmode", defaultValue: 0, },\
|
|
||||||
{ name: "lastIntensity", defaultValue: 1, },\
|
|
||||||
{ name: "sampleAdvance", defaultValue: 0.5, },\
|
{ name: "sampleAdvance", defaultValue: 0.5, },\
|
||||||
]\
|
]\
|
||||||
};\
|
};\
|
||||||
@@ -102,15 +99,10 @@ async function toggleAudio()
|
|||||||
this.rbufferhead = 0|0; \
|
this.rbufferhead = 0|0; \
|
||||||
this.rbuffertail = 0|0; \
|
this.rbuffertail = 0|0; \
|
||||||
this.sampleplace = 0.0; \
|
this.sampleplace = 0.0; \
|
||||||
this.lastIntensity = 0.0; \
|
this.dcoffset = 0.0; \
|
||||||
this.totalsampcount = 0|0; \
|
this.totalsampcount = 0|0; \
|
||||||
this.lastDemodMode = 0|0; \
|
\
|
||||||
this.iirphase = 0.0; /* for FM */\
|
|
||||||
this.lastphase = 0.0; /* for FM */\
|
|
||||||
this.phaseout = 0.0; /* for FM */\
|
|
||||||
this.port.onmessage = (e) => { \
|
this.port.onmessage = (e) => { \
|
||||||
var mulcoeff = 100.0 / Math.fround( this.lastIntensity ); \
|
|
||||||
var demodmode = this.lastDemodMode | 0; \
|
|
||||||
for( var i = 0|0; i < e.data.length|0; i++ ) \
|
for( var i = 0|0; i < e.data.length|0; i++ ) \
|
||||||
{ \
|
{ \
|
||||||
let n = (this.rbufferhead + (1|0))%(8192|0); \
|
let n = (this.rbufferhead + (1|0))%(8192|0); \
|
||||||
@@ -119,41 +111,17 @@ async function toggleAudio()
|
|||||||
this.rbuffertail = (this.rbuffertail + (1|0))%(8192|0); \
|
this.rbuffertail = (this.rbuffertail + (1|0))%(8192|0); \
|
||||||
console.log( `Overflow` ); \
|
console.log( `Overflow` ); \
|
||||||
} \
|
} \
|
||||||
let vv = e.data[i] | 0; \
|
var vv = e.data[i]; \
|
||||||
let vi = vv >> 16; \
|
this.dcoffset = this.dcoffset * 0.995 + vv * 0.005; \
|
||||||
let vq = vv & 0xffff; \
|
this.rbuffer[this.rbufferhead] = vv - this.dcoffset; \
|
||||||
if( vi >= 32768 ) vi = vi-65535; \
|
|
||||||
if( vq >= 32768 ) vq = vq-65535; \
|
|
||||||
let power = Math.sqrt( vi * vi + vq * vq ) * mulcoeff; \
|
|
||||||
let phase = Math.atan2( vi, vq ) * 0.159155078 + 0.5; \
|
|
||||||
if( this.lastDemodMode == 0 ) \
|
|
||||||
{ /* AM */ \
|
|
||||||
this.rbuffer[this.rbufferhead] = power; \
|
|
||||||
} \
|
|
||||||
else if( this.lastDemodMode == 1 ) \
|
|
||||||
{ /* FM */ \
|
|
||||||
var diffphase = phase - this.lastphase; \
|
|
||||||
this.lastphase = phase; \
|
|
||||||
if( diffphase < 0.0 ) diffphase += 1.0; \
|
|
||||||
if( diffphase > 1.0 ) diffphase -= 1.0; \
|
|
||||||
this.iirphase = this.iirphase * 0.999 + diffphase * 0.001; \
|
|
||||||
diffphase -= this.iirphase; \
|
|
||||||
var po = this.phaseout = this.phaseout * 0.993 + diffphase; \
|
|
||||||
if( po < 0.0 ) po += 1.0; \
|
|
||||||
if( po > 1.0 ) po -= 1.0; \
|
|
||||||
this.rbuffer[this.rbufferhead] = po; \
|
|
||||||
} \
|
|
||||||
this.rbufferhead = n; \
|
this.rbufferhead = n; \
|
||||||
} \
|
} \
|
||||||
console.log( this.iirphase ); \
|
|
||||||
}; \
|
}; \
|
||||||
}\
|
}\
|
||||||
\
|
\
|
||||||
process(inputs, outputs, parameters) {\
|
process(inputs, outputs, parameters) {\
|
||||||
/*console.log( parameters.gain[0] );*/ \
|
/*console.log( parameters.gain[0] );*/ \
|
||||||
/*console.log( this.ingestData );*/ \
|
/*console.log( this.ingestData );*/ \
|
||||||
this.lastIntensity = parameters.lastIntensity[0]; \
|
|
||||||
this.lastDemodMode = parameters.demodmode[0]; \
|
|
||||||
let len = outputs[0][0].length; \
|
let len = outputs[0][0].length; \
|
||||||
const sa = Math.fround( parameters.sampleAdvance[0] ); /*float*/ \
|
const sa = Math.fround( parameters.sampleAdvance[0] ); /*float*/ \
|
||||||
var s = Math.fround( this.sampleplace ); /*float*/ \
|
var s = Math.fround( this.sampleplace ); /*float*/ \
|
||||||
@@ -176,7 +144,7 @@ async function toggleAudio()
|
|||||||
nsamp = Math.fround( this.rbuffer[tailnext] ); \
|
nsamp = Math.fround( this.rbuffer[tailnext] ); \
|
||||||
} \
|
} \
|
||||||
var valv = tsamp * (1.0-s) + nsamp * s; \
|
var valv = tsamp * (1.0-s) + nsamp * s; \
|
||||||
outputs[0][0][b] = 0.1*valv*parameters.gain[0]; \
|
outputs[0][0][b] = valv*parameters.gain[0]; \
|
||||||
} \
|
} \
|
||||||
/*console.log( tail + " " + this.rbuffertail + " " + tsamp + " " + nsamp );*/ \
|
/*console.log( tail + " " + this.rbuffertail + " " + tsamp + " " + nsamp );*/ \
|
||||||
this.rbuffertail = tail; \
|
this.rbuffertail = tail; \
|
||||||
@@ -218,7 +186,7 @@ async function toggleAudio()
|
|||||||
gainParam.setValueAtTime( 0, audioContext.currentTime );
|
gainParam.setValueAtTime( 0, audioContext.currentTime );
|
||||||
}
|
}
|
||||||
|
|
||||||
var newVal = 1 - targetGain;
|
var newVal = 0.1 - targetGain;
|
||||||
console.log( "Setting gain to: " + newVal );
|
console.log( "Setting gain to: " + newVal );
|
||||||
let gainParam = playingAudioProcessor.parameters.get("gain");
|
let gainParam = playingAudioProcessor.parameters.get("gain");
|
||||||
gainParam.setValueAtTime( newVal, audioContext.currentTime);
|
gainParam.setValueAtTime( newVal, audioContext.currentTime);
|
||||||
@@ -323,6 +291,10 @@ function updateWebHidDeviceWithParameters( paramlist )
|
|||||||
if( !sendReport ) sendLoopError( "error creating sendFeatureReport" );
|
if( !sendReport ) sendLoopError( "error creating sendFeatureReport" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FMiirphase = 0.0; /* for FM */
|
||||||
|
FMlastphase = 0.0; /* for FM */
|
||||||
|
FMphaseout = 0.0; /* for FM */
|
||||||
|
|
||||||
|
|
||||||
async function sendLoop()
|
async function sendLoop()
|
||||||
{
|
{
|
||||||
@@ -388,19 +360,20 @@ async function sendLoop()
|
|||||||
var x = 253;
|
var x = 253;
|
||||||
for( var i = (IQHistoryHead-1) & (IQHistoryLen-1); i != IQHistoryHead|0; i = (i - 1 + IQHistoryLen) & (IQHistoryLen-1) )
|
for( var i = (IQHistoryHead-1) & (IQHistoryLen-1); i != IQHistoryHead|0; i = (i - 1 + IQHistoryLen) & (IQHistoryLen-1) )
|
||||||
{
|
{
|
||||||
|
let power = MPHistoryArray[i*2+0]; //Math.sqrt( real * real + imag * imag ) * mulcoeff;
|
||||||
|
let phase = MPHistoryArray[i*2+1]; //Math.atan2( real, imag ) * 0.159155078*0.5;
|
||||||
|
ctx.fillRect(x,power*120+10,2,2);
|
||||||
|
ctx.fillRect(x,phase*80+110,2,2);
|
||||||
|
|
||||||
let v = IQHistoryArray[i];
|
let v = IQHistoryArray[i];
|
||||||
let real = (v >> 16);
|
let real = (v >> 16);
|
||||||
let imag = (v & 0xffff);
|
let imag = (v & 0xffff);
|
||||||
if( real > 32767 ) real -= 65536;
|
if( real > 32767 ) real -= 65536;
|
||||||
if( imag > 32767 ) imag -= 65536;
|
if( imag > 32767 ) imag -= 65536;
|
||||||
let power = Math.sqrt( real * real + imag * imag ) * mulcoeff;
|
|
||||||
let phase = Math.atan2( real, imag ) * 0.159155078*0.5;
|
|
||||||
real = real * mulcoeff + 100;
|
real = real * mulcoeff + 100;
|
||||||
imag = imag * mulcoeff + 100;
|
imag = imag * mulcoeff + 100;
|
||||||
if( real < 0 ) real = 0; if( real > 255 ) real = 255;
|
if( real < 0 ) real = 0; if( real > 255 ) real = 255;
|
||||||
if( imag < 0 ) imag = 0; if( imag > 255 ) imag = 255;
|
if( imag < 0 ) imag = 0; if( imag > 255 ) imag = 255;
|
||||||
ctx.fillRect(x,power+10,2,2);
|
|
||||||
ctx.fillRect(x,phase*140+150,2,2);
|
|
||||||
x++;
|
x++;
|
||||||
if( lot > 0 )
|
if( lot > 0 )
|
||||||
{
|
{
|
||||||
@@ -436,10 +409,38 @@ async function sendLoop()
|
|||||||
let time_total = data[1]>>16;
|
let time_total = data[1]>>16;
|
||||||
let time_used = data[1]&0xffff;
|
let time_used = data[1]&0xffff;
|
||||||
let sample_divisor = data[2]&0xffff;
|
let sample_divisor = data[2]&0xffff;
|
||||||
|
let demodbuffer = new Float32Array(numq);
|
||||||
|
let mulcoeff = 100.0 / lastIntensity;
|
||||||
for( var i = 0|0; i < numq; i++ )
|
for( var i = 0|0; i < numq; i++ )
|
||||||
{
|
{
|
||||||
IQHistoryArray[IQHistoryHead++] = data[i+3];
|
let vv = IQHistoryArray[IQHistoryHead] = data[i+3];
|
||||||
if( IQHistoryHead == IQHistoryLen ) IQHistoryHead = 0;
|
let vi = vv >> 16;
|
||||||
|
let vq = vv & 0xffff;
|
||||||
|
if( vi >= 32768 ) vi = vi-65535;
|
||||||
|
if( vq >= 32768 ) vq = vq-65535;
|
||||||
|
let power = Math.sqrt( vi * vi + vq * vq ) * mulcoeff;
|
||||||
|
let phase = Math.atan2( vi, vq ) * 0.159155078 + 0.5;
|
||||||
|
MPHistoryArray[IQHistoryHead*2+0] = power; //Math.sqrt( real * real + imag * imag ) * mulcoeff;
|
||||||
|
MPHistoryArray[IQHistoryHead*2+1] = phase; //Math.atan2( real, imag ) * 0.159155078*0.5;
|
||||||
|
if( targetModulation == 0 )
|
||||||
|
{ /* AM */
|
||||||
|
demodbuffer[i] = power;
|
||||||
|
}
|
||||||
|
else if( targetModulation == 1 )
|
||||||
|
{ /* FM */
|
||||||
|
var diffphase = phase - FMlastphase;
|
||||||
|
this.lastphase = phase;
|
||||||
|
if( diffphase < 0.0 ) diffphase += 1.0;
|
||||||
|
if( diffphase > 1.0 ) diffphase -= 1.0;
|
||||||
|
FMiirphase = FMiirphase * 0.999 + diffphase * 0.001;
|
||||||
|
diffphase -= FMiirphase;
|
||||||
|
var po = FMphaseout = FMphaseout * 0.993 + diffphase;
|
||||||
|
if( po < 0.0 ) po += 1.0;
|
||||||
|
if( po > 1.0 ) po -= 1.0;
|
||||||
|
demodbuffer[i] = po;
|
||||||
|
}
|
||||||
|
|
||||||
|
IQHistoryHead = (IQHistoryHead+1)%IQHistoryLen;
|
||||||
}
|
}
|
||||||
lastIntensity = intensity;
|
lastIntensity = intensity;
|
||||||
lastNumQ = numq;
|
lastNumQ = numq;
|
||||||
@@ -448,15 +449,11 @@ async function sendLoop()
|
|||||||
|
|
||||||
if( audioContext != null && playingAudioProcessor != null )
|
if( audioContext != null && playingAudioProcessor != null )
|
||||||
{
|
{
|
||||||
let lastIntensityParam = playingAudioProcessor.parameters.get("lastIntensity");
|
|
||||||
lastIntensityParam.setValueAtTime( lastIntensity, audioContext.currentTime);
|
|
||||||
|
|
||||||
// TODO: Use crystalmhz
|
// TODO: Use crystalmhz
|
||||||
let sampleAdvance = (144000000.0/sample_divisor) / audioContext.sampleRate;
|
let sampleAdvance = (144000000.0/sample_divisor) / audioContext.sampleRate;
|
||||||
let sampleAdvanceParam = playingAudioProcessor.parameters.get("sampleAdvance");
|
let sampleAdvanceParam = playingAudioProcessor.parameters.get("sampleAdvance");
|
||||||
sampleAdvanceParam.setValueAtTime( sampleAdvance, audioContext.currentTime);
|
sampleAdvanceParam.setValueAtTime( sampleAdvance, audioContext.currentTime);
|
||||||
|
playingAudioProcessor.port.postMessage( demodbuffer );
|
||||||
playingAudioProcessor.port.postMessage( new Uint32Array( data.buffer.slice( 3*4, numq*4 + 3*4 ) ) );
|
|
||||||
}
|
}
|
||||||
goodCount++;
|
goodCount++;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user