Skip to content

Commit f733d1e

Browse files
committed
Fixed colors
1 parent a03a1da commit f733d1e

3 files changed

Lines changed: 54 additions & 15 deletions

File tree

JavaGUI/src/martin/tempest/Main.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ public void run() {
5454
int fid = 0;
5555
@Override
5656
public void onFrameReady(TSDRLibrary lib, BufferedImage frame) {
57-
//viz.drawImage(frame);
58-
try {
59-
ImageIO.write(frame, "bmp", new java.io.File("D:\\temp\\"+(fid++)+".bmp"));
60-
} catch (IOException e) {}
57+
viz.drawImage(frame);
58+
//try {
59+
// ImageIO.write(frame, "bmp", new java.io.File("D:\\temp\\"+(fid++)+".bmp"));
60+
//} catch (IOException e) {}
6161
}
6262

6363
@Override

TSDRPlugin_RawFile/src/TSDRPlugin_RawFile.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#define PERFORMANCE_BENCHMARK (0)
1919
#define ENABLE_LOOP (0)
2020

21+
#define TIME_STRETCH (10)
2122
#define SAMPLES_TO_READ_AT_ONCE (512*1024)
2223

2324
TickTockTimer_t timer;
@@ -77,7 +78,7 @@ int tsdrplugin_readasync(tsdrplugin_readasync_function cb, void *ctx, const char
7778
float * outbuf = (float *) malloc(sizeof(float) * SAMPLES_TO_READ_AT_ONCE);
7879

7980
#if !PERFORMANCE_BENCHMARK
80-
uint32_t delayms = (uint32_t) (1000.0f * (float) SAMPLES_TO_READ_AT_ONCE / (float) samplerate);
81+
uint32_t delayms = (uint32_t) (TIME_STRETCH*1000.0f * (float) SAMPLES_TO_READ_AT_ONCE / (float) samplerate);
8182
if (delayms == 0) delayms = 1;
8283
#endif
8384

TempestSDR/src/TSDRLibrary.c

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ void videodecodingthread(void * ctx) {
113113
mutex_signal((mutex_t *) context->this->mutex_video_stopped);
114114
}
115115

116+
117+
116118
void process(float *buf, uint32_t len, void *ctx) {
117119
tsdr_context_t * context = (tsdr_context_t *) ctx;
118120

@@ -122,7 +124,7 @@ void process(float *buf, uint32_t len, void *ctx) {
122124
int outbufsize = context->bufsize;
123125

124126
const double post = context->this->pixeltimeoversampletime;
125-
const double post1 = 1.0 / post;
127+
const double post1 = 1.0/post;
126128
const int pids = (int) ((size - context->offset) / post);
127129

128130
// resize buffer so it fits
@@ -132,8 +134,8 @@ void process(float *buf, uint32_t len, void *ctx) {
132134
}
133135

134136
const double offset = context->offset;
135-
double t = context->offset + post;
136-
float contrib = context->contributionfromlast;
137+
double t = context->offset;
138+
double contrib = context->contributionfromlast;
137139
const float prev_max = context->max;
138140
const float prev_min = context->min;
139141
const float prev_span = (prev_min == prev_max) ? (1) : (1.0f / (prev_max - prev_min));
@@ -150,18 +152,54 @@ void process(float *buf, uint32_t len, void *ctx) {
150152

151153
const float val = sqrtf(I*I+Q*Q);
152154

153-
const int id1 = id+1;
155+
// we are in case:
156+
// pid
157+
// t (in terms of id)
158+
// . ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! pixels (pid)
159+
// ____|__val__|_______|_______|_______| samples (id)
160+
// id id+1 id+2
154161

155-
while (t <= id1) {
156-
const float pix = (t >= id) ? (val) : ((contrib + val*(t-id))*post1);
162+
if (t < id) {
163+
const float pix = (contrib + val*(t+post-id))*post1;
157164
if (pix > max) max = pix; else if (pix < min) min = pix;
158165
outbuf[pid++] = (pix - prev_min) * prev_span;
159-
t+=post;
160166
contrib = 0;
167+
t=offset+pid*post;
161168
}
162169

163-
const float contrfract = id1-t+post;
170+
// we are in case:
171+
// pid
172+
// t t+post (in terms of id)
173+
// . ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! pixels (pid)
174+
// ____|__val__|_______|_______|_______| samples (id)
175+
// id
176+
177+
while (t+post < id+1) {
178+
const float pix = val;
179+
if (pix > max) max = pix; else if (pix < min) min = pix;
180+
outbuf[pid++] = (pix - prev_min) * prev_span;
181+
t=offset+pid*post;
182+
}
183+
184+
// we are in case:
185+
// pid
186+
// t (in terms of id)
187+
// . ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! pixels (pid)
188+
// ____|__val__|_______|_______|_______| samples (id)
189+
// id id+1 id+2
190+
191+
const float contrfract = id+1-t;
164192
contrib += (contrfract < 0) ? (val) : (contrfract * val);
193+
194+
195+
// gaussian distrib is
196+
// exp(-x^2/(2*s^2))
197+
// s^2 = 0.2 is a nice number
198+
// if we put -1/(2*s^2) = a
199+
// the integral has expansion x + (a*x^3)/3 + (a^2*x^5)/10
200+
// i want this from -1 to 1 to be equal to 1
201+
// so multiply by = 1 / (2 + 2*a/3 + a^2/5)
202+
165203
}
166204

167205
context->bufsize = outbufsize;
@@ -171,8 +209,8 @@ void process(float *buf, uint32_t len, void *ctx) {
171209
context->max = max;
172210
context->min = min;
173211

174-
// if (pid != pids)
175-
// printf("Pid %d; pids %d; t %.4f, size %d, offset %.4f\n", pid, pids, t, size, context->offset);
212+
if (pid != pids)
213+
printf("Pid %d; pids %d; t %.4f, size %d, offset %.4f\n", pid, pids, t, size, context->offset);
176214

177215
cb_add(&context->circbuf, outbuf, pid);
178216
}

0 commit comments

Comments
 (0)