Re: Streaming Audio to CAPI
- From: "Kinfe Tadesse" <tadesse@xxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 26 Apr 2006 17:01:36 +0200
Dear Danilo Kempf,
You can probably implement the counterpart (a 'writer', that is)
easily.
Thanks to your help now things seem in order. However, I need some help to
write the writer functions. Would you please spare some of your precious
time and extract something out of your fertile mind to make me understand
how to write these functions with a few examples as you did for the reader
functions?
Best regards,
Kinfe T.
If you don't mind, feel free to post your code, so we can have a look! I'd
be interested in how you implement the struct-writing thing...
If you try this out you should notice one more thing: your audio will
sound absolutely horrible. All audio-data needs to be sent down to
CAPI bit-flipped -- that is, every byte you send down has to be
mirrored. That is, 0x01 becomes 0x80 and so on. Basically
[abcd|efgh] --> [hgfe|dcba].
Something like this could help:
void flip( unsigned char data, unsigned long len ) {
unsigned long i;
static const unsigned char flipt[256] = {
0x00, 0x80,
/* Lots of elements which you can fill out. */
..., 0xFF
};
for( i=0; i<len; i++ )
data[i] = flipt[data[i]];
}
I have already filled the table. But I didn't understand how the loop
reverses the bits. I simply filled the table but I didn't know what those
hexadecimal numbers stand for.
Hmmm, if you didn't know what those numbers stand for, how did you then
fill
the table?
The idea of this function is as follows: (As soon as you make the first
parameter an unsigned char * instead of a plain unsigned char. Typo
again.)
You have an array of bytes, each of which can take a value from 0 to 255.
(At least on systems where a CHAR_BIT == 8. But I don't think CAPI is
defined on systems where there are more than eight bits to a byte or even
that such systems are still in widespread use.)
What we want in the end is the same array, but with each byte having the
bit-order reversed. So we take each bytes value (0-255 again) and use it
as
an index into our flip-table. This table contains, at the proper
positions,
the byte with bit-order reversed. This reversed value then is written back
into the byte-array we started with in the first place.
There's not much more to be said about that...
Last question, is there anything else I need to implement apart from the
ones you have explained so far?
No, I don't think there's much more left to do then. Even if it might
sound
daunting at first, a basic CAPI application which can accept calls and
stream audio in both directions can be written in a few hundred lines of
code.
Best regards,
Danilo
.
- References:
- Streaming Audio to CAPI
- From: Kinfe Tadesse
- Re: Streaming Audio to CAPI
- From: Danilo Kempf
- Re: Streaming Audio to CAPI
- From: Kinfe Tadesse
- Re: Streaming Audio to CAPI
- From: Danilo Kempf
- Re: Streaming Audio to CAPI
- From: Kinfe Tadesse
- Re: Streaming Audio to CAPI
- From: Danilo Kempf
- Streaming Audio to CAPI
- Prev by Date: receiving a fax
- Next by Date: CAPI Disconnect
- Previous by thread: Re: Streaming Audio to CAPI
- Next by thread: Re: Streaming audio to CAPI
- Index(es):
Relevant Pages
|