@@ -49,7 +49,7 @@ void print_level_meter( const float * buffer, const int num_samples, const int n
49
49
50
50
// Next, output the level of each channel:
51
51
int max_space = 60 ;
52
- printf (" \r " );
52
+ printf (" \r \r " );
53
53
int level_divisions = max_space/num_channels;
54
54
55
55
printf (" [" );
@@ -85,7 +85,7 @@ void print_level_meter( const float * buffer, const int num_samples, const int n
85
85
for ( int k=0 ; k<num_channels-1 ; ++k ) {
86
86
printf (" %.3f, " , levels[k]);
87
87
}
88
- printf (" %.3f\r " , levels[num_channels-1 ]);
88
+ printf (" %.3f" , levels[num_channels-1 ]);
89
89
fflush (stdout);
90
90
}
91
91
@@ -100,10 +100,6 @@ static int pa_callback( const void *inputBuffer, void *outputBuffer, unsigned lo
100
100
// If we've got input data, send it out!
101
101
if ( inputBuffer != NULL ) {
102
102
zmq_send (device->raw_audio_in , inputBuffer, framesPerBuffer*device->num_channels *sizeof (float ), 0 );
103
-
104
- if ( opts.meter ) {
105
- print_level_meter ( (const float *)inputBuffer, framesPerBuffer, device->num_channels );
106
- }
107
103
}
108
104
109
105
if ( outputBuffer != NULL ) {
@@ -347,6 +343,17 @@ void * audio_thread(void * device_ptr) {
347
343
// Send it the pre-mixed buffer of audio
348
344
zmq_send (device->mixed_audio_out , mix_buff, sizeof (float )*mix_buff_len, 0 );
349
345
346
+ int maxsize = 0 ;
347
+ for ( auto &kv : clientMixedInAlready ) {
348
+ maxsize = fmax (clientChunks[kv.first ].size (), maxsize);
349
+ }
350
+
351
+ if ( opts.meter ) {
352
+ print_level_meter ( (const float *)mix_buff, SAMPLES_IN_BUFFER, device->num_channels );
353
+ printf (" (%d)" , maxsize);
354
+ fflush (stdout);
355
+ }
356
+
350
357
if ( device->output_log != NULL )
351
358
device->output_log ->writeData ((const float *)mix_buff, SAMPLES_IN_BUFFER);
352
359
@@ -358,7 +365,7 @@ void * audio_thread(void * device_ptr) {
358
365
if ( clientChunks[kv.first ].size () > 0 ) {
359
366
// Grab the first chunk of audio waiting for me;
360
367
float * chunk = clientChunks[kv.first ][0 ];
361
- clientChunks. erase (clientChunks.begin ());
368
+ clientChunks[kv. first ]. erase (clientChunks[kv. first ] .begin ());
362
369
363
370
// Mix it in, and delete the chunk!
364
371
for ( int i=0 ; i<device->num_channels *SAMPLES_IN_BUFFER; ++i )
@@ -456,14 +463,13 @@ void * audio_thread(void * device_ptr) {
456
463
int dec_len = zmq_msg_size (&msg);
457
464
int num_samples = dec_len/(sizeof (float )*device->num_channels );
458
465
459
- // printf("[0x%x] Got %d samples of %d channels from device!\n", device, num_samples, device->num_channels);
460
- // print_peak_level( (const float *)zmq_msg_data(&msg), num_samples, device->num_channels);
466
+ if ( opts. meter )
467
+ print_level_meter ( (const float *)zmq_msg_data (&msg), num_samples, device->num_channels );
461
468
462
469
if ( input_log != NULL )
463
470
input_log->writeData ((const float *)zmq_msg_data (&msg), num_samples);
464
471
465
472
// Encode it:
466
- // printf("msg size: %d, num_channels: %d\n", zmq_msg_size(&msg), device->num_channels);
467
473
int enc_len = opus_encode_float (device->encoder , (const float *)zmq_msg_data (&msg), num_samples, encoded_data, MAX_DATA_PACKET_LEN );
468
474
if ( enc_len < 0 ) {
469
475
fprintf (stderr, " opus_encode_float() error: %d\n " , enc_len);
0 commit comments