Java sound
I am trying to run sound through an algorithm, yet to be determined, and I need to move information from an input source run the algorithm, then out put it, the information will either be 8-bit , i know how to process this, or 16-bit signed, this I need to turn into a form that I can use, then it needs to be changed back into the 16-bit. the information will be gathered using a TargetDataLine and then sent using a SourceDataLine
andrewjj20
Change it into longs, perform operation, change it back
Change it into floats, perform operations, change it back.
Keep it as signed shorts, perform operations (being carfull not to
overrun the datatype.
They are all much of a muchness. What exactly do you want to do?
you may find the Java Media stuff useful.
matfud
That should have been int not long (although you can use long's if
you feel the perverse desire to).
In general performing your operations (especially if you have a chain
of them) in a larger data type then the input data type, has the
advantage of minimising the amount of error you introduce into your
output.
For example if you add two 16 bit (unsigned) numbers together you
need 17 bits to represent the answer. Your output is 16 bits therefore
you need to dispose of (or round off) the least significant bit to
produce your result. This introduces noise (errors) into your output
even for simple operations.
Imagine that you wish to add the value 65534 to a series of 16 bit (unsigned) numbers:
4, 5, 4, 5, 4, 5, 4 etc.
you need 17 bits to represent the answer. After you truncate the
result to put it back into your unsigned 16 bit output the result is
32769, 32769, 32769, 32769 etc.
The original information has been lost (it is unavoidable but the
effects can be minimised especially if you have a chain of such operations). Understanding this is fundamental when writing DSP
algorithms (and using them).
matfud