Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / March 2007

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Fengyuan - 30 Mar 2007 07:31 GMT
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
Andrew Thompson - 30 Mar 2007 08:05 GMT
..
> I am new to ..

..usenet?

OK.  In that case I will ask you to please
cross-post (AKA x-post), rather than multi-post,
in future.
<http://www.physci.org/codes/javafaq.html#xpost>

(X-post to c.l.j.p./h., w/ f-u to c.l.j.h. only)

Andrew T.
Karl Uppiano - 30 Mar 2007 08:29 GMT
> Hi, All
>
[quoted text clipped - 6 lines]
> 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!
rossum - 30 Mar 2007 12:18 GMT
>Hi, All
>
[quoted text clipped - 3 lines]
>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

>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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.