accessing buffer~

Mar 6, 2011 at 3:29pm

accessing buffer~

hi everybody,
first of all i’m a newbie in programming and i’m writing this external as the final project for my thesis at university.

i’m trying to access a buffer and copy all the values in an array of doubles,
but max crashes everytime i try to access the buffer.

these are the methods i’m trying to write

void fftesi_bang(t_fftesi *x)
{
	post("bang received, provo a leggere il buffer");
	t_buffer *buf = x->l_buf;
	copio_campioni(buf);
}

void copio_campioni(t_buffer *b)
{
	//float *tab;
	long i, chan;
	//double current_samp = 0.0;
	ATOMIC_INCREMENT((int32_t*)&b->b_inuse);
	post("speriamo bene");
	i = 1; chan = 1;
	if (!b->b_valid) {
		ATOMIC_DECREMENT(&b->b_inuse);
		return;
	}
	/*
	//copio il valore corrente in un array di dimensione 4096
	tab = b->b_samples;
	chan = 0; //usiamo solo il canale left
	for(i=0; ib_frames; i++)
	{
		segnale[i] = tab[i];
		post ("letto campioni");
	}
	 */
	ATOMIC_DECREMENT((int32_t*)&b->b_inuse);
	return;
}

the zip file contains the dir placed in MaxSDK-5.1.6/examples/ with my xcode project.

thanks to all

#55362
Mar 6, 2011 at 5:11pm

Hello,

is this code compilable ? i don’t think so.

where segnale is declared ? why *tab is // ?
why chan = 1 then chan = 0 ?

it looks like desesperate try to adapt Tim Place code ;-)

Can you post your zip again (or just the .c) ? don’t forget to “Upload” it.

#199241
Mar 6, 2011 at 6:29pm

Hello,

as i investigated a little,
i have a question about interleaved frames ;

for instance with two channels A and B is it :

AAAAAAAABBBBBBBB

or

ABABABABABABABAB

?

i cannot remember,

thanks …

#199242
Mar 6, 2011 at 7:37pm

the later.

#199243
Mar 6, 2011 at 8:39pm

I’m sorry i didn’t explain!

The part between /* is commented because i was tryin to find my mistake, and the chan=1 i=1 is written just to avoid the warning msg “unused var”

Even the tab declaration is commented necause tab is used in the commented part. The error is of course in the uncommented part!

If you download the zip file you get a buildable dir, but max crashes if i send a bang to left inlet

#199244
Mar 6, 2011 at 9:08pm

I didn’t read abiut the zip… I’ll post it later i’m sorry :P

#199245
Mar 6, 2011 at 10:01pm

here’s the zip

Attachments:
  1. Archivio.zip
#199246
Mar 7, 2011 at 3:12pm

Hello stanzarossa,

a quick example ;

HTH

Attachments:
  1. accessBuffer.zip
#199247
Mar 7, 2011 at 3:35pm

if you are in Milan in the week before Easter, you will get a pair of beer because a little bit of my degree is your.

thanks a lot

Antonio

#199248

You must be logged in to reply to this topic.