0

Im trying to stream values from an buffer, these values are being generated by a sine wave function

When i try to send the values to the driver i have to use this function

snd_pcm_sframes_t snd_pcm_writei(snd_pcm_t *pcm, const void *buffer,
                             snd_pcm_uframes_t size)

The problem for me is i dont understand the const void *buffer

I have a for loop set up to loop through the values in the buffer. Then I have the following to attempt to send each value in the buffer out to the sound driver

frames = snd_pcm_writei(handle, buffer[i], sizeof(buffer));

but it gives an error to do with the const void - it will only let me sound 'buffer' not 'buffer[i]' This is no use to me as it just sends the whole buffer at once to the sound driver which results in noise How can I get around this??? thanks for any help

user2459764
  • 85
  • 1
  • 2
  • 7

2 Answers2

0

buffer[i] is not a pointer unless buffer is an array of pointers. If that's the value you really want, use (const void*)&buffer[i]--"a constant pointer of type void that is the address of the variable in buffer at index 0".

In other words, the compiler message is telling you that the types are mismatched.

Hope this helps :) Good luck.

Ben Brammer
  • 988
  • 4
  • 11
0

You should use &buffer[i] instead of buffer[i] and then pass the correct size of data. How is buffer defined anyway?

n3rd4n1
  • 371
  • 2
  • 8