@@ -236,6 +236,7 @@ struct Input {
236
236
dst.update = true ;
237
237
dst.flags .needReinit = true ;
238
238
dst.sampleRateOffset = std::move (this ->sampleRateOffset );
239
+ dst.freqStartShift = std::move (this ->freqStartShift );
239
240
dst.payloadLength = std::move (this ->payloadLength );
240
241
dst.directSequenceSpread = std::move (this ->directSequenceSpread );
241
242
}
@@ -266,6 +267,7 @@ struct Input {
266
267
267
268
// reinit
268
269
float sampleRateOffset = 0 ;
270
+ int freqStartShift = 0 ;
269
271
int payloadLength = -1 ;
270
272
271
273
// spectrum
@@ -636,10 +638,19 @@ void updateCore() {
636
638
if (inputCurrent.flags .needReinit ) {
637
639
static auto sampleRateInpOld = ggWave->sampleRateInp ();
638
640
static auto sampleRateOutOld = ggWave->sampleRateOut ();
641
+ static auto freqStartShiftOld = 0 ;
642
+
639
643
auto sampleFormatInpOld = ggWave->sampleFormatInp ();
640
644
auto sampleFormatOutOld = ggWave->sampleFormatOut ();
641
645
auto rxProtocolsOld = ggWave->rxProtocols ();
642
646
647
+ for (int i = 0 ; i < GGWAVE_PROTOCOL_COUNT; ++i) {
648
+ GGWave::Protocols::tx ()[i].freqStart = std::max (1 , GGWave::Protocols::tx ()[i].freqStart + inputCurrent.freqStartShift - freqStartShiftOld);
649
+ rxProtocolsOld[i].freqStart = std::max (1 , rxProtocolsOld[i].freqStart + inputCurrent.freqStartShift - freqStartShiftOld);
650
+ }
651
+
652
+ freqStartShiftOld = inputCurrent.freqStartShift ;
653
+
643
654
GGWave::OperatingMode mode = GGWAVE_OPERATING_MODE_RX_AND_TX;
644
655
if (inputCurrent.directSequenceSpread ) mode |= GGWAVE_OPERATING_MODE_USE_DSS;
645
656
@@ -853,6 +864,8 @@ void renderMain() {
853
864
int protocolId = GGWAVE_PROTOCOL_AUDIBLE_FAST;
854
865
bool isSampleRateOffset = false ;
855
866
float sampleRateOffset = -512 .0f ;
867
+ bool isFreqStartShift = false ;
868
+ int freqStartShift = 48 ;
856
869
bool isFixedLength = false ;
857
870
bool directSequenceSpread = false ;
858
871
int payloadLength = 16 ;
@@ -1055,7 +1068,7 @@ void renderMain() {
1055
1068
1056
1069
if (windowId == WindowId::Settings) {
1057
1070
ImGui::BeginChild (" Settings:main" , ImGui::GetContentRegionAvail (), true , ImGuiWindowFlags_NoScrollbar | ImGuiWindowFlags_NoScrollWithMouse);
1058
- ImGui::Text (" Waver v1.5.1 " );
1071
+ ImGui::Text (" Waver v1.5.2 " );
1059
1072
ImGui::Separator ();
1060
1073
1061
1074
ImGui::Text (" %s" , " " );
@@ -1177,7 +1190,10 @@ void renderMain() {
1177
1190
{
1178
1191
const float df = statsCurrent.sampleRate /statsCurrent.samplesPerFrame ;
1179
1192
const auto & protocol = settings.txProtocols [settings.protocolId ];
1180
- ImGui::Text (" %6.2f Hz - %6.2f Hz" , df*protocol.freqStart , df*(protocol.freqStart + float (2 *16 *protocol.bytesPerTx )/protocol.extra ));
1193
+ const auto freqStart = std::max (1 , protocol.freqStart + (settings.isFreqStartShift ? settings.freqStartShift : 0 ));
1194
+ const float f0 = df*freqStart;
1195
+ const float f1 = df*(freqStart + float (2 *16 *protocol.bytesPerTx )/protocol.extra );
1196
+ ImGui::Text (" %6.2f Hz - %6.2f Hz" , f0, f1);
1181
1197
}
1182
1198
1183
1199
// fixed-length
@@ -1204,65 +1220,107 @@ void renderMain() {
1204
1220
if (settings.isFixedLength ) {
1205
1221
ImGui::SameLine ();
1206
1222
ImGui::PushItemWidth (0.5 *ImGui::GetContentRegionAvailWidth ());
1207
- if (ImGui::SliderInt (" Bytes" , &settings.payloadLength , 1 , GGWave::kMaxLengthFixed )) {
1223
+ if (ImGui::DragInt (" Bytes" , &settings.payloadLength , 1 , 1 , GGWave::kMaxLengthFixed )) {
1208
1224
g_buffer.inputUI .update = true ;
1209
1225
g_buffer.inputUI .flags .needReinit = true ;
1210
1226
g_buffer.inputUI .payloadLength = settings.isFixedLength ? settings.payloadLength : -1 ;
1211
1227
}
1212
1228
ImGui::PopItemWidth ();
1213
1229
}
1214
1230
1215
- // Output sample-rate offset
1216
- ImGui::Text (" %s" , " " );
1231
+ // Direct-sequence spread
1232
+ // ImGui::Text("%s", "");
1217
1233
{
1218
1234
auto posSave = ImGui::GetCursorScreenPos ();
1219
1235
ImGui::Text (" %s" , " " );
1220
1236
ImGui::SetCursorScreenPos ({ posSave.x + kLabelWidth , posSave.y });
1221
1237
ImGui::PushTextWrapPos ();
1222
- ImGui::TextDisabled (" Modify the output Sampling Rate " );
1238
+ ImGui::TextDisabled (" Direct-sequence spread " );
1223
1239
ImGui::PopTextWrapPos ();
1224
1240
}
1225
1241
{
1226
1242
auto posSave = ImGui::GetCursorScreenPos ();
1227
- ImGui::Text (" Pitch shift : " );
1243
+ ImGui::Text (" Use DSS : " );
1228
1244
ImGui::SetCursorScreenPos ({ posSave.x + kLabelWidth , posSave.y });
1229
1245
}
1230
- if (ImGui::Checkbox (" ##output-sample-rate-offset " , &settings.isSampleRateOffset )) {
1246
+ if (ImGui::Checkbox (" ##direct-sequence-spread " , &settings.directSequenceSpread )) {
1231
1247
g_buffer.inputUI .update = true ;
1232
1248
g_buffer.inputUI .flags .needReinit = true ;
1233
- g_buffer.inputUI .sampleRateOffset = settings.isSampleRateOffset ? settings. sampleRateOffset : 0 ;
1249
+ g_buffer.inputUI .directSequenceSpread = settings.directSequenceSpread ;
1234
1250
}
1235
1251
1236
- if (settings.isSampleRateOffset ) {
1252
+ // FreqStart offset
1253
+ // ImGui::Text("%s", "");
1254
+ {
1255
+ auto posSave = ImGui::GetCursorScreenPos ();
1256
+ ImGui::Text (" %s" , " " );
1257
+ ImGui::SetCursorScreenPos ({ posSave.x + kLabelWidth , posSave.y });
1258
+ ImGui::PushTextWrapPos ();
1259
+ ImGui::TextDisabled (" Apply tx/rx frequency shift" );
1260
+ ImGui::PopTextWrapPos ();
1261
+ }
1262
+ {
1263
+ auto posSave = ImGui::GetCursorScreenPos ();
1264
+ ImGui::Text (" Freq shift: " );
1265
+ ImGui::SetCursorScreenPos ({ posSave.x + kLabelWidth , posSave.y });
1266
+ }
1267
+ if (ImGui::Checkbox (" ##freq-start-offset" , &settings.isFreqStartShift )) {
1268
+ g_buffer.inputUI .update = true ;
1269
+ g_buffer.inputUI .flags .needReinit = true ;
1270
+ g_buffer.inputUI .freqStartShift = settings.isFreqStartShift ? settings.freqStartShift : 0 ;
1271
+ }
1272
+
1273
+ if (settings.isFreqStartShift ) {
1237
1274
ImGui::SameLine ();
1238
1275
ImGui::PushItemWidth (0.5 *ImGui::GetContentRegionAvailWidth ());
1239
- if (ImGui::SliderFloat ( " Samples " , &settings.sampleRateOffset , - 1000 , 1000 , " %.0f " )) {
1276
+ if (ImGui::DragInt ( " bins " , &settings.freqStartShift , 1 , - 64 , 64 , " %d " )) {
1240
1277
g_buffer.inputUI .update = true ;
1241
1278
g_buffer.inputUI .flags .needReinit = true ;
1242
- g_buffer.inputUI .sampleRateOffset = settings.isSampleRateOffset ? settings.sampleRateOffset : 0 ;
1279
+ g_buffer.inputUI .freqStartShift = settings.isFreqStartShift ? settings.freqStartShift : 0 ;
1243
1280
}
1244
1281
ImGui::PopItemWidth ();
1282
+
1283
+ {
1284
+ auto posSave = ImGui::GetCursorScreenPos ();
1285
+ ImGui::Text (" " );
1286
+ ImGui::SetCursorScreenPos ({ posSave.x + kLabelWidth , posSave.y });
1287
+ }
1288
+ {
1289
+ const float df = statsCurrent.sampleRate /statsCurrent.samplesPerFrame ;
1290
+ ImGui::Text (" %6.2f Hz" , df*settings.freqStartShift );
1291
+ }
1245
1292
}
1246
1293
1247
- // Direct-sequence spread
1248
- ImGui::Text (" %s" , " " );
1294
+ // Output sample-rate offset
1295
+ // ImGui::Text("%s", "");
1249
1296
{
1250
1297
auto posSave = ImGui::GetCursorScreenPos ();
1251
1298
ImGui::Text (" %s" , " " );
1252
1299
ImGui::SetCursorScreenPos ({ posSave.x + kLabelWidth , posSave.y });
1253
1300
ImGui::PushTextWrapPos ();
1254
- ImGui::TextDisabled (" Direct-sequence spread " );
1301
+ ImGui::TextDisabled (" Modify the output Sampling Rate " );
1255
1302
ImGui::PopTextWrapPos ();
1256
1303
}
1257
1304
{
1258
1305
auto posSave = ImGui::GetCursorScreenPos ();
1259
- ImGui::Text (" Use DSS : " );
1306
+ ImGui::Text (" Pitch shift : " );
1260
1307
ImGui::SetCursorScreenPos ({ posSave.x + kLabelWidth , posSave.y });
1261
1308
}
1262
- if (ImGui::Checkbox (" ##direct-sequence-spread " , &settings.directSequenceSpread )) {
1309
+ if (ImGui::Checkbox (" ##output-sample-rate-offset " , &settings.isSampleRateOffset )) {
1263
1310
g_buffer.inputUI .update = true ;
1264
1311
g_buffer.inputUI .flags .needReinit = true ;
1265
- g_buffer.inputUI .directSequenceSpread = settings.directSequenceSpread ;
1312
+ g_buffer.inputUI .sampleRateOffset = settings.isSampleRateOffset ? settings.sampleRateOffset : 0 ;
1313
+ }
1314
+
1315
+ if (settings.isSampleRateOffset ) {
1316
+ ImGui::SameLine ();
1317
+ ImGui::PushItemWidth (0.5 *ImGui::GetContentRegionAvailWidth ());
1318
+ if (ImGui::SliderFloat (" Samples" , &settings.sampleRateOffset , -1000 , 1000 , " %.0f" )) {
1319
+ g_buffer.inputUI .update = true ;
1320
+ g_buffer.inputUI .flags .needReinit = true ;
1321
+ g_buffer.inputUI .sampleRateOffset = settings.isSampleRateOffset ? settings.sampleRateOffset : 0 ;
1322
+ }
1323
+ ImGui::PopItemWidth ();
1266
1324
}
1267
1325
1268
1326
// rx protocols
0 commit comments