how to create random noise, convert to xml and send to tcp/ip socket?

F

Fengyuan

Hi, All

I am new to Java, and really need to your help in this moment.

I would like to create a random noise signal (at this point any signal
is ok, later on I would like to one with the distribution I defined),
and convert the signal into xml format and send to a TCP/IP socket.

I am reading help files to try to figure out how to do that. Is there
anyone can give me some ideas, or some information?

Thank you.

Fengyuan
 
K

Karl Uppiano

Fengyuan said:
Hi, All

I am new to Java, and really need to your help in this moment.

I would like to create a random noise signal (at this point any signal
is ok, later on I would like to one with the distribution I defined),
and convert the signal into xml format and send to a TCP/IP socket.

I am reading help files to try to figure out how to do that. Is there
anyone can give me some ideas, or some information?

Audio as XML will be horribly inefficient. But I need to know...

What sample rate?
How many bits per sample?
PCM or perceptual coded?

You can make random noise from java.lang.Math.random, but probably not in
real time. There are other ways you can make random noise. I seem to recall
an algorithm, such as XOR with a randomly-generated integer (seed), and then
left shift, XOR with n-1, etc. I think this generates random numbers with a
rectangular probability density.

Here is some DSP assembly code with a pseudo-random dither generator:
http://www.w9gr.com/cw1ktms.html -- It isn't Java, but you should be able to
use the algorithm. Search for the word "dither" in the document.

Audio is basically unstructured, or perhaps I should say, all the same
structure. I am trying to figure out how you would organize the audio in the
XML document. What would the XML elements represent? Further, since XML is
basically text, you would probably have to base-64 encode the audio to
translate the intrinsically binary audio into legal XML characters - oh! The
humanity!
 
R

rossum

Hi, All

I am new to Java, and really need to your help in this moment.

I would like to create a random noise signal (at this point any signal
is ok, later on I would like to one with the distribution I defined),
and convert the signal into xml format and send to a TCP/IP socket.
How random do you need your signal to be? For example, is this going
to be used for cryptographic purposes or just for simulation.
Cryptographically secure random (java.security.SecureRandom) is not
the same as simulation random (java.util.Random). If you are on a
Linux/Unix system you may have dev/random and dev/urandom available as
well. You can also use a physical device to generate randomness, for
example thermal noise in a Zener diode. There are ways of stretching
a little initial randomness into larger amounts of pseudo-randomness,
since physical devices are often limited in how much randomness they
can safely produce.

Once digitised, your random noise signal will be seen by the computer
as a series of n-bit integers, which can be further seen as a stream
of bytes. XML cannot handle bytes, it can only handle certain
characters. Hence for XML transmission you need to convert your byte
stream into characters. The usual way to do this is to convert the
byte stream to Base64. I have not been able to find a Base64
converter in the standard Java libraries, but Google will soon find a
number of third party implementations.

As has been pointed out, this will be horribly inefficient.

rossum
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top