Hello, i am new to bela. I have a problem sending data through UDP. I read 8 channel microphone datas and send it through UDP port. I tried many approaches to send the 8 channel signal without channels being mixed up. My last solution is to create 8 different UdpClients.

    audio_client0 = new UdpClient(remotePort0,remoteIP);   // UDP client is initialized
    audio_client1 = new UdpClient(remotePort1,remoteIP);   // UDP client is initialized
    audio_client2 = new UdpClient(remotePort2,remoteIP);   // UDP client is initialized
    audio_client3 = new UdpClient(remotePort3,remoteIP);   // UDP client is initialized
    audio_client4 = new UdpClient(remotePort4,remoteIP);   // UDP client is initialized
    audio_client5 = new UdpClient(remotePort5,remoteIP);   // UDP client is initialized
    audio_client6 = new UdpClient(remotePort6,remoteIP);   // UDP client is initialized
    audio_client7 = new UdpClient(remotePort7,remoteIP);   // UDP client is initialized

Send 8 channel with 8 different UDP clients on 8 different ports as:

	audio_client0->send(&gInputs[0], 16384);
	audio_client1->send(&gInputs[1], 16384);
	audio_client2->send(&gInputs[2], 16384);
	audio_client3->send(&gInputs[3], 16384);
	audio_client4->send(&gInputs[4], 16384);
	audio_client5->send(&gInputs[5], 16384);
	audio_client6->send(&gInputs[6], 16384);
	audio_client7->send(&gInputs[7], 16384);`

But i am receiving almost the copies of 0'th channel. In all channels. Can you help me about what could have been causing this problem ?

Thank You

PS: microphone read code:

void render(BelaContext *context, void *userData)
{
	// second_time = time(NULL);
	// printf("%i", second_time - first_time, "\n");
	
	// loops to store audio inputs
	for(unsigned int n = 0; n < context->audioFrames; ++n)  // loop to read all frames, processing frame by frame to ensure syncronisation
	{
		// getting audio samples from all channels
		for(unsigned int c = 0; c < context->audioInChannels; ++c)  // loop to read all channels
		{
			gInputs[c][n] = audioRead(context, n, c);  // read audio of n th frame, c th channel
		}
	}

Can you show all of the relevant portions of your code? What block size are you running this at?

I am using 4096 bytes per frame.
Here is my code just for a reference:

/*
--------------------------------------------
Block Based UDP Audio Streamer
--------------------------------------------
When the program begins it will attempt to allocate enough memory to store audio signals in one block.
If you request an excessive amount of RAM then the program may fail when starting or while running.
The program records the input audio and it stores the input samples into the array `gInputs[]`.
Audio samples are publishing via UDP protochol. Since publishing all block data is not feasible, channel by channel 
data is transferring
*/

#include <Bela.h> 						     // bela main header file	
#include <libraries/AudioFile/AudioFile.h>	 // audio interaction library
#include <vector>							 // vector library
#include <string>							 // string library
#include <libraries/UdpClient/UdpClient.h>   // udp client library
#include <ctime>

std::vector<std::vector<float>> gInputs;    // 2 dimensional vector for audio samples, consists channels and their frames
// UDP Communication

UdpClient* audio_client0; 
UdpClient* audio_client1; 
UdpClient* audio_client2; 
UdpClient* audio_client3; 
UdpClient* audio_client4; 
UdpClient* audio_client5; 
UdpClient* audio_client6; 
UdpClient* audio_client7; 

			// remote IP port
int remotePort0 =40000;						// remote IP port
int remotePort1 =41000;						// remote IP port
int remotePort2 =42000;						// remote IP port
int remotePort3 =43000;						// remote IP port
int remotePort4 =44000;						// remote IP port
int remotePort5 =45000;						// remote IP port
int remotePort6 =46000;						// remote IP port
int remotePort7 =47000;						// remote IP port

const char* remoteIP = "192.168.6.1";	    // remote IP, where data will be published


void sendToMatlab(void*);
float msg[4] = {0.1,0.4,1.2,1.5};
unsigned int first_time;
unsigned int second_time;
bool start_8ch = true;

// creating zeros array
float zeros_array[4096] = {0};

bool setup(BelaContext *context, void *userData)
{
	gInputs.resize(context->audioInChannels);   // sizing first dimension of gInputs array which is channel number
	// If we have too many channels or too many frames to store, we may run out of RAM and
	// the program will fail to start.
	try {
		for(auto& c : gInputs)
			c.resize(context->audioFrames);   // sizing second dimension of gInputs array which is frame size
	} catch (std::exception& e) {             // error case; inform the user
		fprintf(stderr, "Error while allocating memory. Maybe you are asking to record too many frames and/or too many channels\n");
		return false;
	}
```
	
    audio_client0 = new UdpClient(remotePort0,remoteIP);   // UDP client is initialized
    audio_client1 = new UdpClient(remotePort1,remoteIP);   // UDP client is initialized
    audio_client2 = new UdpClient(remotePort2,remoteIP);   // UDP client is initialized
    audio_client3 = new UdpClient(remotePort3,remoteIP);   // UDP client is initialized
    audio_client4 = new UdpClient(remotePort4,remoteIP);   // UDP client is initialized
    audio_client5 = new UdpClient(remotePort5,remoteIP);   // UDP client is initialized
    audio_client6 = new UdpClient(remotePort6,remoteIP);   // UDP client is initialized
    audio_client7 = new UdpClient(remotePort7,remoteIP);   // UDP client is initialized
    
return true; } void render(BelaContext *context, void *userData) { // second_time = time(NULL); // printf("%i", second_time - first_time, "\n"); // loops to store audio inputs for(unsigned int n = 0; n < context->audioFrames; ++n) // loop to read all frames, processing frame by frame to ensure syncronisation { // getting audio samples from all channels for(unsigned int c = 0; c < context->audioInChannels; ++c) // loop to read all channels { gInputs[c][n] = audioRead(context, n, c); // read audio of n th frame, c th channel } } // all data in this block has been read audio_client0->send(&gInputs[0], 16384); audio_client1->send(&gInputs[1], 16384); audio_client2->send(&gInputs[2], 16384); audio_client3->send(&gInputs[3], 16384); audio_client4->send(&gInputs[4], 16384); audio_client5->send(&gInputs[5], 16384); audio_client6->send(&gInputs[6], 16384); audio_client7->send(&gInputs[7], 16384); } void cleanup(BelaContext *context, void *userData) { // no need to any cleanup }`
    4 days later

    BatnVader audio_client0->send(&gInputs[0], 16384);
    audio_client1->send(&gInputs[1], 16384);
    audio_client2->send(&gInputs[2], 16384);
    audio_client3->send(&gInputs[3], 16384);
    audio_client4->send(&gInputs[4], 16384);
    audio_client5->send(&gInputs[5], 16384);
    audio_client6->send(&gInputs[6], 16384);
    audio_client7->send(&gInputs[7], 16384);

    You should be using the likes of gInputs[0].data(), e.g.:

    audio_client0->send(gInputs[0].data(), gInputs[0].size() * sizeof(float));

    Also you may want to do yourself a favour and use a vector of pointers for audio_client.