summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrimio <vasi.vilvoiu@gmail.com>2019-01-09 00:08:57 +0200
committerrimio <vasi.vilvoiu@gmail.com>2019-01-09 00:08:57 +0200
commit45753482e99ec37d9cab0d898f7b75d64f658a3c (patch)
tree5ec45bde04095e345cad6306c0091b90f4b03364
parent85acad49b42bf3734249dae13429a26395a68a03 (diff)
VIS code
-rw-r--r--CMakeLists.txt2
-rw-r--r--src/encoder.c46
-rw-r--r--src/libsstv.template.h1
-rw-r--r--src/luts.c2
-rw-r--r--src/luts.h2
-rw-r--r--src/sstv.c25
-rw-r--r--src/sstv.h6
-rw-r--r--src/tools/sstv-encode.cpp29
-rw-r--r--util/genluts.py6
-rw-r--r--util/view.py31
10 files changed, 134 insertions, 16 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5eda742..5ce0377 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -60,5 +60,5 @@ if (BUILD_TOOLS)
set_property (TARGET ${PROJECT_NAME}-encode PROPERTY LINKER_LANGUAGE CXX)
set_property (TARGET ${PROJECT_NAME}-encode PROPERTY CXX_STANDARD 14)
target_include_directories(${PROJECT_NAME}-encode PUBLIC "${SRC_DIR}/tools" PUBLIC "${INCLUDE_DIR}")
- target_link_libraries (${PROJECT_NAME}-encode ${PROJECT_NAME} glog gflags X11)
+ target_link_libraries (${PROJECT_NAME}-encode ${PROJECT_NAME} glog gflags X11 sndfile)
endif (BUILD_TOOLS) \ No newline at end of file
diff --git a/src/encoder.c b/src/encoder.c
index ecee41f..57b6ad5 100644
--- a/src/encoder.c
+++ b/src/encoder.c
@@ -20,9 +20,22 @@
*/
typedef enum {
SSTV_ENCODER_STATE_START,
+
SSTV_ENCODER_STATE_LEADER_TONE_1,
SSTV_ENCODER_STATE_BREAK,
SSTV_ENCODER_STATE_LEADER_TONE_2,
+
+ SSTV_ENCODER_STATE_VIS_START_BIT = 99,
+ SSTV_ENCODER_STATE_VIS_BIT0 = 100,
+ SSTV_ENCODER_STATE_VIS_BIT1 = 101,
+ SSTV_ENCODER_STATE_VIS_BIT2 = 102,
+ SSTV_ENCODER_STATE_VIS_BIT3 = 103,
+ SSTV_ENCODER_STATE_VIS_BIT4 = 104,
+ SSTV_ENCODER_STATE_VIS_BIT5 = 105,
+ SSTV_ENCODER_STATE_VIS_BIT6 = 106,
+ SSTV_ENCODER_STATE_VIS_BIT7 = 107,
+ SSTV_ENCODER_STATE_VIS_STOP_BIT,
+
SSTV_ENCODER_STATE_END
} sstv_encoder_state_t;
@@ -184,6 +197,35 @@ sstv_encode_state_change(sstv_encoder_context_t *context)
return SSTV_OK;
}
+ /* VIS start bit */
+ if (context->state == SSTV_ENCODER_STATE_LEADER_TONE_2) {
+ context->state = SSTV_ENCODER_STATE_VIS_START_BIT;
+ context->fsk.phase_delta = DPHASE_FROM_FREQ(1200, context->sample_rate);
+ context->fsk.remaining_samples = REMAINING_SAMPLES_US(30000, context->sample_rate);
+ return SSTV_OK;
+ }
+
+ /* VIS bits */
+ if ((context->state >= SSTV_ENCODER_STATE_VIS_START_BIT)
+ && (context->state < SSTV_ENCODER_STATE_VIS_BIT7))
+ {
+ uint8_t visp = sstv_get_visp_code(context->mode);
+ uint8_t bit = visp >> (context->state - SSTV_ENCODER_STATE_VIS_START_BIT) & 0x1;
+
+ context->state ++;
+ context->fsk.phase_delta = DPHASE_FROM_FREQ((bit ? 1100 : 1300), context->sample_rate);
+ context->fsk.remaining_samples = REMAINING_SAMPLES_US(30000, context->sample_rate);
+ return SSTV_OK;
+ }
+
+ /* VIS stop bit */
+ if (context->state == SSTV_ENCODER_STATE_VIS_BIT7) {
+ context->state = SSTV_ENCODER_STATE_VIS_STOP_BIT;
+ context->fsk.phase_delta = DPHASE_FROM_FREQ(1200, context->sample_rate);
+ context->fsk.remaining_samples = REMAINING_SAMPLES_US(30000, context->sample_rate);
+ return SSTV_OK;
+ }
+
/* debug */
context->state = SSTV_ENCODER_STATE_END;
return SSTV_OK;
@@ -244,6 +286,10 @@ sstv_encode(void *ctx, sstv_signal_t *signal)
case SSTV_SAMPLE_INT8:
((int8_t *)signal->buffer)[signal->count] = SSTV_SIN_INT10_INT8[context->fsk.phase >> 6];
break;
+
+ case SSTV_SAMPLE_UINT8:
+ ((uint8_t *)signal->buffer)[signal->count] = SSTV_SIN_INT10_UINT8[context->fsk.phase >> 6];
+ break;
case SSTV_SAMPLE_INT16:
((int16_t *)signal->buffer)[signal->count] = SSTV_SIN_INT10_INT16[context->fsk.phase >> 6];
diff --git a/src/libsstv.template.h b/src/libsstv.template.h
index ec120ef..76c50ee 100644
--- a/src/libsstv.template.h
+++ b/src/libsstv.template.h
@@ -102,6 +102,7 @@ typedef struct {
* Signal sample type
*/
typedef enum {
+ SSTV_SAMPLE_UINT8,
SSTV_SAMPLE_INT8,
SSTV_SAMPLE_INT16
} sstv_sample_type_t;
diff --git a/src/luts.c b/src/luts.c
index 58ed7e9..7e73b88 100644
--- a/src/luts.c
+++ b/src/luts.c
@@ -9,5 +9,7 @@
int8_t SSTV_SIN_INT10_INT8[1024] = { 0, 1, 2, 2, 3, 4, 5, 5, 6, 7, 8, 9, 9, 10, 11, 12, 12, 13, 14, 15, 16, 16, 17, 18, 19, 19, 20, 21, 22, 22, 23, 24, 25, 26, 26, 27, 28, 29, 29, 30, 31, 32, 32, 33, 34, 35, 35, 36, 37, 38, 38, 39, 40, 41, 41, 42, 43, 44, 44, 45, 46, 46, 47, 48, 49, 49, 50, 51, 51, 52, 53, 54, 54, 55, 56, 56, 57, 58, 58, 59, 60, 61, 61, 62, 63, 63, 64, 65, 65, 66, 67, 67, 68, 69, 69, 70, 71, 71, 72, 72, 73, 74, 74, 75, 76, 76, 77, 78, 78, 79, 79, 80, 81, 81, 82, 82, 83, 84, 84, 85, 85, 86, 86, 87, 88, 88, 89, 89, 90, 90, 91, 91, 92, 93, 93, 94, 94, 95, 95, 96, 96, 97, 97, 98, 98, 99, 99, 100, 100, 101, 101, 102, 102, 102, 103, 103, 104, 104, 105, 105, 106, 106, 106, 107, 107, 108, 108, 109, 109, 109, 110, 110, 111, 111, 111, 112, 112, 112, 113, 113, 113, 114, 114, 114, 115, 115, 115, 116, 116, 116, 117, 117, 117, 118, 118, 118, 118, 119, 119, 119, 120, 120, 120, 120, 121, 121, 121, 121, 122, 122, 122, 122, 122, 123, 123, 123, 123, 123, 124, 124, 124, 124, 124, 124, 125, 125, 125, 125, 125, 125, 125, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 126, 125, 125, 125, 125, 125, 125, 125, 124, 124, 124, 124, 124, 124, 123, 123, 123, 123, 123, 122, 122, 122, 122, 122, 121, 121, 121, 121, 120, 120, 120, 120, 119, 119, 119, 118, 118, 118, 118, 117, 117, 117, 116, 116, 116, 115, 115, 115, 114, 114, 114, 113, 113, 113, 112, 112, 112, 111, 111, 111, 110, 110, 109, 109, 109, 108, 108, 107, 107, 106, 106, 106, 105, 105, 104, 104, 103, 103, 102, 102, 102, 101, 101, 100, 100, 99, 99, 98, 98, 97, 97, 96, 96, 95, 95, 94, 94, 93, 93, 92, 91, 91, 90, 90, 89, 89, 88, 88, 87, 86, 86, 85, 85, 84, 84, 83, 82, 82, 81, 81, 80, 79, 79, 78, 78, 77, 76, 76, 75, 74, 74, 73, 72, 72, 71, 71, 70, 69, 69, 68, 67, 67, 66, 65, 65, 64, 63, 63, 62, 61, 61, 60, 59, 58, 58, 57, 56, 56, 55, 54, 54, 53, 52, 51, 51, 50, 49, 49, 48, 47, 46, 46, 45, 44, 44, 43, 42, 41, 41, 40, 39, 38, 38, 37, 36, 35, 35, 34, 33, 32, 32, 31, 30, 29, 29, 28, 27, 26, 26, 25, 24, 23, 22, 22, 21, 20, 19, 19, 18, 17, 16, 16, 15, 14, 13, 12, 12, 11, 10, 9, 9, 8, 7, 6, 5, 5, 4, 3, 2, 2, 1, 0, -1, -2, -2, -3, -4, -5, -5, -6, -7, -8, -9, -9, -10, -11, -12, -12, -13, -14, -15, -16, -16, -17, -18, -19, -19, -20, -21, -22, -22, -23, -24, -25, -26, -26, -27, -28, -29, -29, -30, -31, -32, -32, -33, -34, -35, -35, -36, -37, -38, -38, -39, -40, -41, -41, -42, -43, -44, -44, -45, -46, -46, -47, -48, -49, -49, -50, -51, -51, -52, -53, -54, -54, -55, -56, -56, -57, -58, -58, -59, -60, -61, -61, -62, -63, -63, -64, -65, -65, -66, -67, -67, -68, -69, -69, -70, -71, -71, -72, -72, -73, -74, -74, -75, -76, -76, -77, -78, -78, -79, -79, -80, -81, -81, -82, -82, -83, -84, -84, -85, -85, -86, -86, -87, -88, -88, -89, -89, -90, -90, -91, -91, -92, -93, -93, -94, -94, -95, -95, -96, -96, -97, -97, -98, -98, -99, -99, -100, -100, -101, -101, -102, -102, -102, -103, -103, -104, -104, -105, -105, -106, -106, -106, -107, -107, -108, -108, -109, -109, -109, -110, -110, -111, -111, -111, -112, -112, -112, -113, -113, -113, -114, -114, -114, -115, -115, -115, -116, -116, -116, -117, -117, -117, -118, -118, -118, -118, -119, -119, -119, -120, -120, -120, -120, -121, -121, -121, -121, -122, -122, -122, -122, -122, -123, -123, -123, -123, -123, -124, -124, -124, -124, -124, -124, -125, -125, -125, -125, -125, -125, -125, -126, -126, -126, -126, -126, -126, -126, -126, -126, -126, -126, -127, -127, -127, -127, -127, -127, -127, -127, -127, -127, -127, -127, -127, -127, -127, -127, -127, -127, -127, -127, -127, -127, -127, -127, -127, -127, -127, -127, -127, -126, -126, -126, -126, -126, -126, -126, -126, -126, -126, -126, -125, -125, -125, -125, -125, -125, -125, -124, -124, -124, -124, -124, -124, -123, -123, -123, -123, -123, -122, -122, -122, -122, -122, -121, -121, -121, -121, -120, -120, -120, -120, -119, -119, -119, -118, -118, -118, -118, -117, -117, -117, -116, -116, -116, -115, -115, -115, -114, -114, -114, -113, -113, -113, -112, -112, -112, -111, -111, -111, -110, -110, -109, -109, -109, -108, -108, -107, -107, -106, -106, -106, -105, -105, -104, -104, -103, -103, -102, -102, -102, -101, -101, -100, -100, -99, -99, -98, -98, -97, -97, -96, -96, -95, -95, -94, -94, -93, -93, -92, -91, -91, -90, -90, -89, -89, -88, -88, -87, -86, -86, -85, -85, -84, -84, -83, -82, -82, -81, -81, -80, -79, -79, -78, -78, -77, -76, -76, -75, -74, -74, -73, -72, -72, -71, -71, -70, -69, -69, -68, -67, -67, -66, -65, -65, -64, -63, -63, -62, -61, -61, -60, -59, -58, -58, -57, -56, -56, -55, -54, -54, -53, -52, -51, -51, -50, -49, -49, -48, -47, -46, -46, -45, -44, -44, -43, -42, -41, -41, -40, -39, -38, -38, -37, -36, -35, -35, -34, -33, -32, -32, -31, -30, -29, -29, -28, -27, -26, -26, -25, -24, -23, -22, -22, -21, -20, -19, -19, -18, -17, -16, -16, -15, -14, -13, -12, -12, -11, -10, -9, -9, -8, -7, -6, -5, -5, -4, -3, -2, -2, -1, };
+uint8_t SSTV_SIN_INT10_UINT8[1024] = { 128, 128, 129, 130, 131, 131, 132, 133, 134, 135, 135, 136, 137, 138, 138, 139, 140, 141, 142, 142, 143, 144, 145, 145, 146, 147, 148, 149, 149, 150, 151, 152, 152, 153, 154, 155, 155, 156, 157, 158, 158, 159, 160, 161, 162, 162, 163, 164, 165, 165, 166, 167, 167, 168, 169, 170, 170, 171, 172, 173, 173, 174, 175, 176, 176, 177, 178, 178, 179, 180, 181, 181, 182, 183, 183, 184, 185, 186, 186, 187, 188, 188, 189, 190, 190, 191, 192, 192, 193, 194, 194, 195, 196, 196, 197, 198, 198, 199, 200, 200, 201, 202, 202, 203, 203, 204, 205, 205, 206, 207, 207, 208, 208, 209, 210, 210, 211, 211, 212, 213, 213, 214, 214, 215, 215, 216, 217, 217, 218, 218, 219, 219, 220, 220, 221, 221, 222, 222, 223, 224, 224, 225, 225, 226, 226, 227, 227, 228, 228, 228, 229, 229, 230, 230, 231, 231, 232, 232, 233, 233, 234, 234, 234, 235, 235, 236, 236, 236, 237, 237, 238, 238, 238, 239, 239, 240, 240, 240, 241, 241, 241, 242, 242, 242, 243, 243, 243, 244, 244, 244, 245, 245, 245, 246, 246, 246, 246, 247, 247, 247, 248, 248, 248, 248, 249, 249, 249, 249, 250, 250, 250, 250, 250, 251, 251, 251, 251, 251, 252, 252, 252, 252, 252, 252, 253, 253, 253, 253, 253, 253, 253, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 254, 253, 253, 253, 253, 253, 253, 253, 252, 252, 252, 252, 252, 252, 251, 251, 251, 251, 251, 250, 250, 250, 250, 250, 249, 249, 249, 249, 248, 248, 248, 248, 247, 247, 247, 246, 246, 246, 246, 245, 245, 245, 244, 244, 244, 243, 243, 243, 242, 242, 242, 241, 241, 241, 240, 240, 240, 239, 239, 238, 238, 238, 237, 237, 236, 236, 236, 235, 235, 234, 234, 234, 233, 233, 232, 232, 231, 231, 230, 230, 229, 229, 228, 228, 228, 227, 227, 226, 226, 225, 225, 224, 224, 223, 222, 222, 221, 221, 220, 220, 219, 219, 218, 218, 217, 217, 216, 215, 215, 214, 214, 213, 213, 212, 211, 211, 210, 210, 209, 208, 208, 207, 207, 206, 205, 205, 204, 203, 203, 202, 202, 201, 200, 200, 199, 198, 198, 197, 196, 196, 195, 194, 194, 193, 192, 192, 191, 190, 190, 189, 188, 188, 187, 186, 186, 185, 184, 183, 183, 182, 181, 181, 180, 179, 178, 178, 177, 176, 176, 175, 174, 173, 173, 172, 171, 170, 170, 169, 168, 167, 167, 166, 165, 165, 164, 163, 162, 162, 161, 160, 159, 158, 158, 157, 156, 155, 155, 154, 153, 152, 152, 151, 150, 149, 149, 148, 147, 146, 145, 145, 144, 143, 142, 142, 141, 140, 139, 138, 138, 137, 136, 135, 135, 134, 133, 132, 131, 131, 130, 129, 128, 128, 127, 126, 125, 124, 124, 123, 122, 121, 120, 120, 119, 118, 117, 117, 116, 115, 114, 113, 113, 112, 111, 110, 110, 109, 108, 107, 106, 106, 105, 104, 103, 103, 102, 101, 100, 100, 99, 98, 97, 97, 96, 95, 94, 93, 93, 92, 91, 90, 90, 89, 88, 88, 87, 86, 85, 85, 84, 83, 82, 82, 81, 80, 79, 79, 78, 77, 77, 76, 75, 74, 74, 73, 72, 72, 71, 70, 69, 69, 68, 67, 67, 66, 65, 65, 64, 63, 63, 62, 61, 61, 60, 59, 59, 58, 57, 57, 56, 55, 55, 54, 53, 53, 52, 52, 51, 50, 50, 49, 48, 48, 47, 47, 46, 45, 45, 44, 44, 43, 42, 42, 41, 41, 40, 40, 39, 38, 38, 37, 37, 36, 36, 35, 35, 34, 34, 33, 33, 32, 31, 31, 30, 30, 29, 29, 28, 28, 27, 27, 27, 26, 26, 25, 25, 24, 24, 23, 23, 22, 22, 21, 21, 21, 20, 20, 19, 19, 19, 18, 18, 17, 17, 17, 16, 16, 15, 15, 15, 14, 14, 14, 13, 13, 13, 12, 12, 12, 11, 11, 11, 10, 10, 10, 9, 9, 9, 9, 8, 8, 8, 7, 7, 7, 7, 6, 6, 6, 6, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9, 9, 10, 10, 10, 11, 11, 11, 12, 12, 12, 13, 13, 13, 14, 14, 14, 15, 15, 15, 16, 16, 17, 17, 17, 18, 18, 19, 19, 19, 20, 20, 21, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 27, 28, 28, 29, 29, 30, 30, 31, 31, 32, 33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 38, 39, 40, 40, 41, 41, 42, 42, 43, 44, 44, 45, 45, 46, 47, 47, 48, 48, 49, 50, 50, 51, 52, 52, 53, 53, 54, 55, 55, 56, 57, 57, 58, 59, 59, 60, 61, 61, 62, 63, 63, 64, 65, 65, 66, 67, 67, 68, 69, 69, 70, 71, 72, 72, 73, 74, 74, 75, 76, 77, 77, 78, 79, 79, 80, 81, 82, 82, 83, 84, 85, 85, 86, 87, 88, 88, 89, 90, 90, 91, 92, 93, 93, 94, 95, 96, 97, 97, 98, 99, 100, 100, 101, 102, 103, 103, 104, 105, 106, 106, 107, 108, 109, 110, 110, 111, 112, 113, 113, 114, 115, 116, 117, 117, 118, 119, 120, 120, 121, 122, 123, 124, 124, 125, 126, 127, };
+
int16_t SSTV_SIN_INT10_INT16[1024] = { 0, 201, 402, 603, 804, 1005, 1206, 1407, 1608, 1809, 2009, 2210, 2410, 2611, 2811, 3012, 3212, 3412, 3612, 3811, 4011, 4210, 4410, 4609, 4808, 5007, 5205, 5404, 5602, 5800, 5998, 6195, 6393, 6590, 6786, 6983, 7179, 7375, 7571, 7767, 7962, 8157, 8351, 8545, 8739, 8933, 9126, 9319, 9512, 9704, 9896, 10087, 10278, 10469, 10659, 10849, 11039, 11228, 11417, 11605, 11793, 11980, 12167, 12353, 12539, 12725, 12910, 13094, 13279, 13462, 13645, 13828, 14010, 14191, 14372, 14553, 14732, 14912, 15090, 15269, 15446, 15623, 15800, 15976, 16151, 16325, 16499, 16673, 16846, 17018, 17189, 17360, 17530, 17700, 17869, 18037, 18204, 18371, 18537, 18703, 18868, 19032, 19195, 19357, 19519, 19680, 19841, 20000, 20159, 20317, 20475, 20631, 20787, 20942, 21096, 21250, 21403, 21554, 21705, 21856, 22005, 22154, 22301, 22448, 22594, 22739, 22884, 23027, 23170, 23311, 23452, 23592, 23731, 23870, 24007, 24143, 24279, 24413, 24547, 24680, 24811, 24942, 25072, 25201, 25329, 25456, 25582, 25708, 25832, 25955, 26077, 26198, 26319, 26438, 26556, 26674, 26790, 26905, 27019, 27133, 27245, 27356, 27466, 27575, 27683, 27790, 27896, 28001, 28105, 28208, 28310, 28411, 28510, 28609, 28706, 28803, 28898, 28992, 29085, 29177, 29268, 29358, 29447, 29534, 29621, 29706, 29791, 29874, 29956, 30037, 30117, 30195, 30273, 30349, 30424, 30498, 30571, 30643, 30714, 30783, 30852, 30919, 30985, 31050, 31113, 31176, 31237, 31297, 31356, 31414, 31470, 31526, 31580, 31633, 31685, 31736, 31785, 31833, 31880, 31926, 31971, 32014, 32057, 32098, 32137, 32176, 32213, 32250, 32285, 32318, 32351, 32382, 32412, 32441, 32469, 32495, 32521, 32545, 32567, 32589, 32609, 32628, 32646, 32663, 32678, 32692, 32705, 32717, 32728, 32737, 32745, 32752, 32757, 32761, 32765, 32766, 32767, 32766, 32765, 32761, 32757, 32752, 32745, 32737, 32728, 32717, 32705, 32692, 32678, 32663, 32646, 32628, 32609, 32589, 32567, 32545, 32521, 32495, 32469, 32441, 32412, 32382, 32351, 32318, 32285, 32250, 32213, 32176, 32137, 32098, 32057, 32014, 31971, 31926, 31880, 31833, 31785, 31736, 31685, 31633, 31580, 31526, 31470, 31414, 31356, 31297, 31237, 31176, 31113, 31050, 30985, 30919, 30852, 30783, 30714, 30643, 30571, 30498, 30424, 30349, 30273, 30195, 30117, 30037, 29956, 29874, 29791, 29706, 29621, 29534, 29447, 29358, 29268, 29177, 29085, 28992, 28898, 28803, 28706, 28609, 28510, 28411, 28310, 28208, 28105, 28001, 27896, 27790, 27683, 27575, 27466, 27356, 27245, 27133, 27019, 26905, 26790, 26674, 26556, 26438, 26319, 26198, 26077, 25955, 25832, 25708, 25582, 25456, 25329, 25201, 25072, 24942, 24811, 24680, 24547, 24413, 24279, 24143, 24007, 23870, 23731, 23592, 23452, 23311, 23170, 23027, 22884, 22739, 22594, 22448, 22301, 22154, 22005, 21856, 21705, 21554, 21403, 21250, 21096, 20942, 20787, 20631, 20475, 20317, 20159, 20000, 19841, 19680, 19519, 19357, 19195, 19032, 18868, 18703, 18537, 18371, 18204, 18037, 17869, 17700, 17530, 17360, 17189, 17018, 16846, 16673, 16499, 16325, 16151, 15976, 15800, 15623, 15446, 15269, 15090, 14912, 14732, 14553, 14372, 14191, 14010, 13828, 13645, 13462, 13279, 13094, 12910, 12725, 12539, 12353, 12167, 11980, 11793, 11605, 11417, 11228, 11039, 10849, 10659, 10469, 10278, 10087, 9896, 9704, 9512, 9319, 9126, 8933, 8739, 8545, 8351, 8157, 7962, 7767, 7571, 7375, 7179, 6983, 6786, 6590, 6393, 6195, 5998, 5800, 5602, 5404, 5205, 5007, 4808, 4609, 4410, 4210, 4011, 3811, 3612, 3412, 3212, 3012, 2811, 2611, 2410, 2210, 2009, 1809, 1608, 1407, 1206, 1005, 804, 603, 402, 201, 0, -201, -402, -603, -804, -1005, -1206, -1407, -1608, -1809, -2009, -2210, -2410, -2611, -2811, -3012, -3212, -3412, -3612, -3811, -4011, -4210, -4410, -4609, -4808, -5007, -5205, -5404, -5602, -5800, -5998, -6195, -6393, -6590, -6786, -6983, -7179, -7375, -7571, -7767, -7962, -8157, -8351, -8545, -8739, -8933, -9126, -9319, -9512, -9704, -9896, -10087, -10278, -10469, -10659, -10849, -11039, -11228, -11417, -11605, -11793, -11980, -12167, -12353, -12539, -12725, -12910, -13094, -13279, -13462, -13645, -13828, -14010, -14191, -14372, -14553, -14732, -14912, -15090, -15269, -15446, -15623, -15800, -15976, -16151, -16325, -16499, -16673, -16846, -17018, -17189, -17360, -17530, -17700, -17869, -18037, -18204, -18371, -18537, -18703, -18868, -19032, -19195, -19357, -19519, -19680, -19841, -20000, -20159, -20317, -20475, -20631, -20787, -20942, -21096, -21250, -21403, -21554, -21705, -21856, -22005, -22154, -22301, -22448, -22594, -22739, -22884, -23027, -23170, -23311, -23452, -23592, -23731, -23870, -24007, -24143, -24279, -24413, -24547, -24680, -24811, -24942, -25072, -25201, -25329, -25456, -25582, -25708, -25832, -25955, -26077, -26198, -26319, -26438, -26556, -26674, -26790, -26905, -27019, -27133, -27245, -27356, -27466, -27575, -27683, -27790, -27896, -28001, -28105, -28208, -28310, -28411, -28510, -28609, -28706, -28803, -28898, -28992, -29085, -29177, -29268, -29358, -29447, -29534, -29621, -29706, -29791, -29874, -29956, -30037, -30117, -30195, -30273, -30349, -30424, -30498, -30571, -30643, -30714, -30783, -30852, -30919, -30985, -31050, -31113, -31176, -31237, -31297, -31356, -31414, -31470, -31526, -31580, -31633, -31685, -31736, -31785, -31833, -31880, -31926, -31971, -32014, -32057, -32098, -32137, -32176, -32213, -32250, -32285, -32318, -32351, -32382, -32412, -32441, -32469, -32495, -32521, -32545, -32567, -32589, -32609, -32628, -32646, -32663, -32678, -32692, -32705, -32717, -32728, -32737, -32745, -32752, -32757, -32761, -32765, -32766, -32767, -32766, -32765, -32761, -32757, -32752, -32745, -32737, -32728, -32717, -32705, -32692, -32678, -32663, -32646, -32628, -32609, -32589, -32567, -32545, -32521, -32495, -32469, -32441, -32412, -32382, -32351, -32318, -32285, -32250, -32213, -32176, -32137, -32098, -32057, -32014, -31971, -31926, -31880, -31833, -31785, -31736, -31685, -31633, -31580, -31526, -31470, -31414, -31356, -31297, -31237, -31176, -31113, -31050, -30985, -30919, -30852, -30783, -30714, -30643, -30571, -30498, -30424, -30349, -30273, -30195, -30117, -30037, -29956, -29874, -29791, -29706, -29621, -29534, -29447, -29358, -29268, -29177, -29085, -28992, -28898, -28803, -28706, -28609, -28510, -28411, -28310, -28208, -28105, -28001, -27896, -27790, -27683, -27575, -27466, -27356, -27245, -27133, -27019, -26905, -26790, -26674, -26556, -26438, -26319, -26198, -26077, -25955, -25832, -25708, -25582, -25456, -25329, -25201, -25072, -24942, -24811, -24680, -24547, -24413, -24279, -24143, -24007, -23870, -23731, -23592, -23452, -23311, -23170, -23027, -22884, -22739, -22594, -22448, -22301, -22154, -22005, -21856, -21705, -21554, -21403, -21250, -21096, -20942, -20787, -20631, -20475, -20317, -20159, -20000, -19841, -19680, -19519, -19357, -19195, -19032, -18868, -18703, -18537, -18371, -18204, -18037, -17869, -17700, -17530, -17360, -17189, -17018, -16846, -16673, -16499, -16325, -16151, -15976, -15800, -15623, -15446, -15269, -15090, -14912, -14732, -14553, -14372, -14191, -14010, -13828, -13645, -13462, -13279, -13094, -12910, -12725, -12539, -12353, -12167, -11980, -11793, -11605, -11417, -11228, -11039, -10849, -10659, -10469, -10278, -10087, -9896, -9704, -9512, -9319, -9126, -8933, -8739, -8545, -8351, -8157, -7962, -7767, -7571, -7375, -7179, -6983, -6786, -6590, -6393, -6195, -5998, -5800, -5602, -5404, -5205, -5007, -4808, -4609, -4410, -4210, -4011, -3811, -3612, -3412, -3212, -3012, -2811, -2611, -2410, -2210, -2009, -1809, -1608, -1407, -1206, -1005, -804, -603, -402, -201, };
diff --git a/src/luts.h b/src/luts.h
index 6332a38..c6a3411 100644
--- a/src/luts.h
+++ b/src/luts.h
@@ -12,6 +12,8 @@
#include <stddef.h>
extern int8_t SSTV_SIN_INT10_INT8[1024];
+extern uint8_t SSTV_SIN_INT10_UINT8[1024];
+
extern int16_t SSTV_SIN_INT10_INT16[1024];
#endif \ No newline at end of file
diff --git a/src/sstv.c b/src/sstv.c
index 44a0cb5..07c7123 100644
--- a/src/sstv.c
+++ b/src/sstv.c
@@ -176,6 +176,7 @@ sstv_pack_signal(sstv_signal_t *sig, sstv_sample_type_t type, size_t capacity, v
switch(type) {
case SSTV_SAMPLE_INT8:
+ case SSTV_SAMPLE_UINT8:
sig->size = capacity;
break;
@@ -194,4 +195,28 @@ sstv_pack_signal(sstv_signal_t *sig, sstv_sample_type_t type, size_t capacity, v
/* done */
return SSTV_OK;
+}
+
+uint8_t
+sstv_get_visp_code(sstv_mode_t mode)
+{
+ switch (mode) {
+ case SSTV_MODE_PD90:
+ return 99;
+
+ case SSTV_MODE_PD120:
+ return 95;
+
+ case SSTV_MODE_PD160:
+ return 226;
+
+ case SSTV_MODE_PD180:
+ return 96;
+
+ case SSTV_MODE_PD240:
+ return 225;
+
+ default:
+ return 0;
+ }
} \ No newline at end of file
diff --git a/src/sstv.h b/src/sstv.h
index 4b0279a..f36969d 100644
--- a/src/sstv.h
+++ b/src/sstv.h
@@ -16,4 +16,10 @@
extern sstv_malloc_t sstv_malloc_user;
extern sstv_free_t sstv_free_user;
+/*
+ * Utility functions
+ */
+extern uint8_t
+sstv_get_visp_code(sstv_mode_t mode);
+
#endif \ No newline at end of file
diff --git a/src/tools/sstv-encode.cpp b/src/tools/sstv-encode.cpp
index 4daf370..4ffd6c7 100644
--- a/src/tools/sstv-encode.cpp
+++ b/src/tools/sstv-encode.cpp
@@ -7,6 +7,7 @@
#include <iostream>
#include <malloc.h>
+#include <sndfile.h>
#include <glog/logging.h>
#include <gflags/gflags.h>
@@ -23,6 +24,7 @@ extern "C" {
DEFINE_bool(logtostderr, false, "Only log to stderr");
DEFINE_string(mode, "", "SSTV mode for encoder");
DEFINE_string(input, "", "input image");
+DEFINE_string(output, "", "output WAV file");
DEFINE_uint64(sample_rate, 48000, "output audio sample rate");
int main(int argc, char **argv)
@@ -38,6 +40,9 @@ int main(int argc, char **argv)
if (FLAGS_input == "") {
LOG(FATAL) << "Input image filename not provided, use --input";
}
+ if (FLAGS_output == "") {
+ LOG(FATAL) << "Output WAV file not provided, use --output";
+ }
if (FLAGS_mode == "") {
LOG(FATAL) << "Encoding mode not provided, use --mode";
}
@@ -55,9 +60,9 @@ int main(int argc, char **argv)
}
/* create a sample buffer for output */
- int8_t samp_buffer[128 * 1024];
+ uint8_t samp_buffer[128 * 1024];
sstv_signal_t signal;
- if (sstv_pack_signal(&signal, SSTV_SAMPLE_INT8, 128 * 1024, samp_buffer) != SSTV_OK) {
+ if (sstv_pack_signal(&signal, SSTV_SAMPLE_INT16, 128 * 1024, samp_buffer) != SSTV_OK) {
LOG(FATAL) << "sstv_pack_signal() failed";
}
@@ -77,6 +82,16 @@ int main(int argc, char **argv)
LOG(FATAL) << "NULL encoder received";
}
+ /* open WAV file */
+ SF_INFO wavinfo;
+ wavinfo.samplerate = FLAGS_sample_rate;
+ wavinfo.channels = 1;
+ wavinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16;
+ SNDFILE *wavfile = sf_open(FLAGS_output.c_str(), SFM_WRITE, &wavinfo);
+ if (!wavfile) {
+ LOG(FATAL) << "sf_open() failed: " << sf_strerror(NULL);
+ }
+
/* encode */
while (true) {
/* encode block */
@@ -85,11 +100,8 @@ int main(int argc, char **argv)
LOG(FATAL) << "sstv_encode() failed with rc " << rc;
}
- /* DEBUG: print block as csv */
- for (size_t i=0; i < signal.count; i ++) {
- std::cout << (int)((int8_t *)signal.buffer)[i] << std::endl;
- }
- std::cout << std::endl << std::endl;
+ /* write to sound file */
+ sf_write_short(wavfile, (int16_t *)signal.buffer, signal.count);
/* exit case */
if (rc == SSTV_ENCODE_END) {
@@ -97,6 +109,9 @@ int main(int argc, char **argv)
}
}
+ /* close wav file */
+ sf_close(wavfile);
+
/* cleanup */
LOG(INFO) << "Cleaning up";
if (sstv_delete_encoder(ctx) != SSTV_OK) {
diff --git a/util/genluts.py b/util/genluts.py
index fcaead9..4bf07c5 100644
--- a/util/genluts.py
+++ b/util/genluts.py
@@ -21,6 +21,12 @@ for s in sn * 127:
f.write(str(int(np.around(s))) + ', ')
f.write('};\n\n')
+# SSTV_SIN_INT10_UINT8
+f.write('uint8_t SSTV_SIN_INT10_UINT8[1024] = { ')
+for s in (sn + 1) / 2 * 255:
+ f.write(str(int(np.around(s))) + ', ')
+f.write('};\n\n')
+
# SSTV_SIN_INT10_INT16
f.write('int16_t SSTV_SIN_INT10_INT16[1024] = { ')
for s in sn * 32767:
diff --git a/util/view.py b/util/view.py
index b6e95fe..60b3a47 100644
--- a/util/view.py
+++ b/util/view.py
@@ -1,11 +1,26 @@
-import sys
-import numpy as np
import matplotlib.pyplot as plt
+import numpy as np
+import wave
+import sys
+
+
+spf = wave.open('test.wav','r')
+
+#Extract Raw Audio from Wav File
+signal = spf.readframes(-1)
+signal = np.fromstring(signal, 'Int16')
+signal = signal.astype(np.float32)
+
+
+#If Stereo
+if spf.getnchannels() == 2:
+ print('Just mono files')
+ sys.exit(0)
-f = open('test.csv')
-lines = [int(l.replace('\n', '')) for l in f.readlines()[:-2]]
-f.close()
+#plt.figure(1)
+#plt.title('Signal Wave...')
+#plt.plot(signal)
+#plt.show()
-s = np.array(lines)
-plt.plot(s)
-plt.show()
+plt.specgram(signal, Fs=48000)
+plt.show() \ No newline at end of file