Hi all

In order to store audio data more efficiently in netpd presets and also
to transmit live audio through OSC, I'm thinking of ways to convert an
signal to a 16-bit stream represented as two signals, one for each
byte, the first for MSB and the second for LSB. I already came up with
a few solutions, but I'm not totally happy with any of them because
they are not very efficient or/and have strange edge cases. It turns
out what seems a simple task is a bit more complex and probably has
quiet a few totally different solutions.

I would be interested to see with what solutions people come up with.
Consider it a puzzle, a brain teaser (in case you're done writing your
paper for pdcon and need some distraction).

Requirements:
 * It must be done in signal domain (I was doing it in message domain
   yet, but performance is obviously bad)
 * Only vanilla objects are allowed.
 * Input is in the range -1 to 1. Input outside this range should be
   clipped and not wrapped around.
 * Output is two signals, each consisting of an integer value between
   0 and 255
 * The two bytes represent a 16-bit _signed_ integer

You can compare your output with the message version in attached patch.
If this generates interest and makes some people participate, I'll
disclose my solutions after people submitted their solutions.

#N canvas 99 78 582 336 10;
#X obj 55 64 hsl 300 15 -1 1 0 0 empty empty empty -2 -8 0 10 -262144
-1 -1 22000 1;
#X floatatom 52 40 5 0 0 0 - - -, f 5;
#X obj 201 104 sig~;
#X floatatom 52 291 5 0 0 0 - - -, f 5;
#X floatatom 149 289 5 0 0 0 - - -, f 5;
#X floatatom 52 266 5 0 0 0 - - -, f 5;
#X floatatom 151 263 5 0 0 0 - - -, f 5;
#N canvas 0 43 355 239 float-to-16bit 0;
#X obj 28 74 * 32768;
#X obj 28 94 t a a;
#X obj 28 134 div 256;
#X obj 28 154 mod 256;
#X obj 91 139 mod 256;
#X obj 28 22 inlet;
#X obj 28 190 outlet;
#X obj 91 190 outlet;
#X connect 0 0 1 0;
#X connect 1 0 2 0;
#X connect 1 1 4 0;
#X connect 2 0 3 0;
#X connect 3 0 6 0;
#X connect 4 0 7 0;
#X connect 5 0 0 0;
#X restore 52 156 pd float-to-16bit;
#X msg 83 11 0;
#X msg 20 11 -1;
#X msg 48 11 -0.5;
#X msg 113 11 0.5;
#X msg 141 11 1;
#X obj 201 253 snapshot~;
#X obj 348 246 snapshot~;
#X obj 408 217 metro 100;
#X obj 408 188 loadbang;
#N canvas 354 448 421 285 sig-to-16bit-converter 0;
#X obj 16 18 inlet~;
#X obj 21 251 outlet~;
#X obj 321 252 outlet~;
#X restore 201 158 pd sig-to-16bit-converter;
#X text 366 158 <- what to put there?;
#X connect 0 0 2 0;
#X connect 0 0 7 0;
#X connect 1 0 0 0;
#X connect 2 0 17 0;
#X connect 7 0 5 0;
#X connect 7 1 6 0;
#X connect 8 0 1 0;
#X connect 9 0 1 0;
#X connect 10 0 1 0;
#X connect 11 0 1 0;
#X connect 12 0 1 0;
#X connect 13 0 3 0;
#X connect 14 0 4 0;
#X connect 15 0 13 0;
#X connect 15 0 14 0;
#X connect 16 0 15 0;
#X connect 17 0 13 0;
#X connect 17 1 14 0;

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
[email protected] mailing list
UNSUBSCRIBE and account-management -> 
https://lists.puredata.info/listinfo/pd-list

Reply via email to