I posted a question about audio streams once before. I subsequently found out that the reason my code wasn't compiling was because I was using C++ and not C. The type exchanging stuff (IMHO) is better in C. Now, how would I go about doing audio streams in C++? Any thoughts?
the reason my code wasn't compiling was because I was using C++ and not C. The type exchanging stuff (IMHO) is better in C. Now, how would I go about doing audio streams in C++?
Post source.
AUDIOSTREAM *stream; ... stream = play_audio_stream(BUFFER_SIZE, 8, FALSE, SAMPLING_FREQUENCY, 255, 128); ... ... unsigned char *buffer = (unsigned char *)get_audio_stream_buffer(stream); ...
if you use 8 bit sound and
AUDIOSTREAM *stream; ... stream = play_audio_stream(BUFFER_SIZE, 16, FALSE, SAMPLING_FREQUENCY, 255, 128); ... ... unsigned short *buffer = (unsigned short *)get_audio_stream_buffer(stream); ...
if you use 16 bit sound.
Evert, I really don't think that's necessary as I hardly have any and I'm just looking for the framework.
EDIT:
Thank you, miran!
If your source is giving you problems `because you're using C++, not C', then you should post said source so that we can say what you should change or add to make it work. Otherwise it wouldn't be really useful to post random thoughts about it, would it?
Btw, "the type exchanging stuff" is called typecasting or casting for short. C is a weakly typed language (not really, but that's not the point), because when you have void* it means you have a pointer to anything. C++ on the other hand is strongly typed which means that void* shouldn't even be valid code (it's valid as a special case for backwards compatibility with C). In C++ when you have a pointer to something (void* is like a pointer to nothing in C++) and want to use it as if it was a pointer to something else, you need to cast it to that something else type. For your needs (using a C library that uses void pointers in C++) a simple C-style cast is good enough. A C style cast is when you write the type you want to cast to in front of the variable you want to cast in parenthesis. For example to cast a variable called x of type float to type int, you would write (int)x, and when you want to cast a variable called buffer of type void* to type int*, you type (int*)buffer.
(never mind (grumble, grumble))
So what's C++ typecasting like?
EDIT: Oh, wait. What you showed me is C++ typecasting, yeah?