Hello, i am using bela just to read microphone outputs and send the live datas to the computer in real time. When i record the microphones and listen to the wav files. All microphones are working clearly but, when i try to decimate then transmit the microphone outputs. I am receiving nonsense values like e^-33,-38 some very high values like e37 and after the code sends 3-4 frames it gives segmentation error.

I share the code snippets below:


std::vector<std::vector<float>> gInputs;
std::vector<std::vector<float>> gOutputs;
std::vector<std::vector<float>> gOut_temp;
std::vector<float> gFile;    // 2 dimensional vector for audio samples, consists channels and their frames
std::string gFilenameInputs = "dene_5.wav";
// UDP Communication

UdpClient* audio_client; 

int remotePort =40001;						// remote IP port
const char* remoteIP = "192.168.7.1";	    // remote IP, where data will be published
unsigned int gWrittenFrames = 0; // how many frames written to gOutBuf
unsigned int byte_0 = 0;
unsigned int byte_size = 0;
unsigned int frame_counter = 0;
const int frame_stop = 96;


std::vector<std::vector<float>> gFileBuf(1, std::vector<float>(frame_stop*8*256, 0));
std::vector<Biquad> gBiquads; // filters to process the inputs


bool setup(BelaContext *context, void *userData)
{
	gFileBuf.resize(1);
	gInputs.resize(8);
	gOutputs.resize(1);
	gOut_temp.resize(8);
	try {
		for(auto& k : gInputs)
			k.resize(1024);
		for(auto& k : gOut_temp)
			k.resize(1024);
		for(auto& t : gOutputs)
			t.resize(2*1024);
		for(auto& c : gFileBuf)
			c.resize(frame_stop*8*256);

		} 
		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;
		}
		
		Biquad::Settings settings {
		.fs = 48000,
		.type = Biquad::lowpass,
		.cutoff = 10000,
		.q = 0.707,
		.peakGainDb = 0,
		};
	

	gBiquads.resize(std::min(context->audioInChannels, context->audioOutChannels), Biquad(settings));
    audio_client = new UdpClient(remotePort,remoteIP);   // UDP client is initialized
	byte_size = context->audioFrames;
	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
	{
		unsigned int c;
		// process audio inputs through the filter, write to the audio outputs and store the audio outputs
		for(c = 0; c < gBiquads.size(); ++c) {
			float in = audioRead(context, n, c);
			float out = gBiquads[c].process(in);
			gOut_temp[c][gWrittenFrames] = out;
			audioWrite(context, n, c, out);
			if (n%4 ==0){
				gOutputs[0][c*256+n] = out;
			}
			
		}

		++gWrittenFrames;		
	}

	/*
	for (unsigned int i = 0; i<512;++i)
		gOutputs[0][i] = 0.3;
	printf("%f %f %f \n",gOutputs[0][128],gOutputs[0][440],gOutputs[0][1670]);
	*/

		
	byte_0= audio_client->send(&gOutputs[0], 8192);

I am trying to solve this problem for almost 4 days now. I added the decimation operation after i tried the send the data as it is and still without the decimation i cannot send the datas without a problem.
https://forum.bela.io/d/3913-problem-with-sending-multichannel-audio-signal-through-udp/2

I think i missed something small yet important because this task should not be that hard 🙂

Any help is appreciated.
Thank you

Btw, even when i try to send some constant values in array. I still receive nonsense values.

gOutputs[0] is a std::vector<float>, so if you simply take its address, it will have gibberish in it. You need to use gOutputs[x].data().