Skip to content

Commit 4651606

Browse files
committed
WIP! bgm_xyscope: handle 32 bit samples
1 parent c581934 commit 4651606

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/modules/bgm_xyscope.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#define PLOSSFAC ((BUFFER_FRAMES) / 64)
2626

2727
enum samplesize {
28-
SIZE_8, SIZE_16
28+
SIZE_8, SIZE_16, SIZE_32
2929
};
3030

3131
static snd_pcm_t * scope_pcm;
@@ -60,6 +60,7 @@ static int dotimeout;
6060
static oscore_task scope_task;
6161

6262
#define SM_ALGORITHM(sample, shr, sub) (((byte) (sample >> shr)) - sub)
63+
#define SM_ALGORITHM_SCALE(sample, scale, sub) (((byte) ((float) sample * (scale))) - sub)
6364
#define LD_ALGORITHM(typ, shr, sub) \
6465
for (int indx = 0; indx < BUFFER_FRAMES; indx++) { \
6566
typ sampleA = ((typ *) bufferA)[indx * (sf_2c ? 2 : 1)]; \
@@ -120,6 +121,12 @@ static void * thread_func(void * ign) {
120121
} else {
121122
LD_ALGORITHM(byte, 0, 0x80);
122123
}
124+
} else if (sf_sampsize == SIZE_32) {
125+
if (sf_us) {
126+
LD_ALGORITHM(unsigned int, 24, 0);
127+
} else {
128+
LD_ALGORITHM(unsigned int, 24, 0x80);
129+
}
123130
}
124131
// This actually connects it all together
125132
for (int i = 0; i < frames; i++) {
@@ -284,6 +291,9 @@ int init(int modulen, char* argstr) {
284291
case SIZE_16:
285292
bytesPerSample = 2;
286293
break;
294+
case SIZE_32:
295+
bytesPerSample = 4;
296+
break;
287297
}
288298

289299
bufferA = malloc(BUFFER_FRAMES * (sf_2c ? 2 : 1) * bytesPerSample);

0 commit comments

Comments
 (0)