|
Hi,
I want to convert a ULAW encoded .wav file into a PCM encoded one. The ULAW encoded .wav file is of 8 bit, mono with 8Khz sample rate. How can I achieve this. I have written a code below but it gives error that the conversion is not supported. I am using javax.sound.sampled class. below is the code.
try{
File temp = new File("C:/temp.wav");
File fileout = new File("C:/1java.wav");
AudioInputStream sourceaudio = AudioSystem.getAudioInputStream(temp);
AudioFormat targetformat = new AudioFormat(new AudioFormat.Encoding("PCM_UNSIGNED"),8000,16,0,8,8000,true);
AudioFileFormat.Type targettype = AudioFileFormat.Type.WAVE;
AudioInputStream targetaudiostream = AudioSystem.getAudioInputStream(targetformat,sourceaudio);
AudioSystem.write(targetaudiostream, targettype, fileout);
}
catch(Exception e){
out.println("Error in audio format conversion");
e.printStackTrace();
}
|
|
|
|
|
I personally did not try this but I found this link that will solve your problem
http://www.mms-computing.co.uk/uk/co/mmscomputing/sound/
Do tell if you figure it out
|
|
|
|
|
Hi,
I was able to solve it using the inherent java audio class javax.sound.sampled. I convert an input audio file encoded in uLaw to PCM and then write the PCM file into an Audiostream. Code is given below.
try{
File filein = new File("C:/sourcefile.wav");
File fileout = new File("C:/PCMfile.wav");
AudioInputStream sourceaudio = AudioSystem.getAudioInputStream(filein);
AudioFormat format = sourceaudio.getFormat();
if (format.getEncoding() != AudioFormat.Encoding.PCM_SIGNED) {
format = new AudioFormat(
AudioFormat.Encoding.PCM_SIGNED,
format.getSampleRate(),
format.getSampleSizeInBits() * 2,
format.getChannels(),
format.getFrameSize() * 2,
format.getFrameRate(),
true);
}
AudioFileFormat.Type targettype = AudioFileFormat.Type.WAVE;
AudioInputStream targetaudiostream = AudioSystem.getAudioInputStream(format, sourceaudio);
AudioSystem.write(targetaudiostream, targettype, fileout);
System.out.println("PCM encoded file generated successfully.");
sourceaudio.close();
targetaudiostream.close();
} catch (Exception e) {
out.println("Error in audio format conversion");
e.printStackTrace();
}
|
|
|
|
|
I have an ActiveX control in my Java SWT application. I'm using OleClientSite to host the ActiveX control.
The ActiveX control has 2 methods I'm interested in. Here are their COM interface definitions:
[id(5)]
void easyFoo([in] int fooType);
[id(20)]
void problemFoo([in] VARIANT floatArray);
Still with me?
I'd like to call the above 2 functions from Java. Here's my Java code:
OleAutomation myActiveXObject = new OleAutomation(...);
int fooType = 1;
Variant[] easyFooArgs = new Variant[] {
new Variant(fooType)
};
myActiveXObject.invoke(5, easyFooArgs);
float[] myFloats = new float[] { 2.5f, 42.0f };
Variant[] problemFooArgs = new Variant[] {
new Variant(myFloats)
};
myActiveXobject.invoke(20, problemFooArgs);
The error is on the problemFooArgs line: there is no Variant constructor that accepts float[].
How do I send a float array over to the ActiveX control?
Religiously blogging on the intarwebs since the early 21st century: Kineti L'Tziyon
Judah Himango
|
|
|
|
|
Hi,
I'm encountering exactly same problem as you were.
Did you find out the solution for this?
I've spent few weeks to solve this problem, but no luck so far.
Please let me know.
Thanks!
|
|
|
|
|
i have just learnt java programming,can anybody please help me out on how i can improve my programming skills in java.
|
|
|
|
|
|
|
Just noticed this guy has spammed this in a few places. Waste of a good link, but I'll put it to use.
Thanks.
|
|
|
|
|
Hi,
how can i open a DATE dialog box, i have a need to create scheduled messages
so i want to let the user select the date and time from a dialog box like you have
when you press the time on the task bar inside Windows
Thanks
|
|
|
|
|
There is no standard date dialog in Java. Google for "java date control" or similar and you will find plenty of information.
|
|
|
|
|
Hi,I have one final project about chat application. this application has login panel which are username and password, client and server panel. I tried to finish this project but I have a problem this problem is when the client send a message all of client can see this message but I want to send this message only who I want to send it. I have a user list and I did this list as well. I know my problem is the client message send to the server and server send all of clients and all of clients connected localhost. so How can I fix this problem, Please someone helps me about my project. If it is possible someone can send solving java codes. Thank you alls.
|
|
|
|
|
You need to define to which client you want to send the message.
Tell the server whom you want to chat to and let the server select the client you choose. For this, each client should have a unique IP - or (on localhost) at least a unique port, on which the client is reachable.
greets
Torsten
|
|
|
|
|
Hi
I have a problem with my graph colouring code,have pasted my methods which I believed were correct until I found two different answers whn using algorithm and code.
Its about colouring different countries using minimul different colours.
Im supposed to get an array[0,0,1,1,2,2,2,2,2,1].
but i get [0,0,0,0,0,0,1,1,0,0].
pliz help.
public void ApproxColour(){
int v, new_colour;
for(v = 0; v<CountryList.size(); v++){
colour[v] = -1;
}
sortVertices();
colour[0]=0;
for(int i=1; i<CountryList.size(); i++){
colour[i] = FindSmallestfreecolour(sorted_country[i]);
}
System.out.println(Arrays.toString(colour));
//return colour;
}
public int FindSmallestfreecolour(String Country){
int w;
boolean used[] = new boolean[CountryList.size()];
for(w=0; w<CountryList.size();w++){
if(isAdjacent(Country, CountryList.get(w).getName()) && colour[w] != -1){
used[colour[w]] = true;
}
}
w=0;
while (used[w])
w++;
return w;
}
public void sortVertices(){
int position = 0;
//System.out.println(Arrays.toString(degrees));
for(int j = 0; j < degrees.length; j++){
int Largest = getLargestDegree();
sorted[position] = Largest;
degrees[Largest] = -1;
position++;
country[j] = CountryList.get(j).getName();
}
//System.out.println(Arrays.toString(sorted));
int var;
for(int i=0; i<sorted.length; i++){
var = sorted[i];
sorted_country[i] = country[var];
}
//System.out.println(Arrays.toString(sorted_country));
}
|
|
|
|
|
I am writing a web-based system with java. There are some labels and reports printing. Each requires different printers which are connected to the same client computer.
How could I set so that, when I Print Doc A, document A would print to printer A, and when clicked Print for Doc B, document B would print to printer B.
The URL for both the documents are different. doc A is on http://www.xyz.com and doc b is on http://www.abc.com.
info: It is a web-based system used within a lan. So each user use the system with a fixed computer.
|
|
|
|
|
i started to learn java. i have middle level information about visual c# and C languages. how can i find electronical project about java ?let me suggest some learning way java language.i need some sample projects and codes.
Thanks for reading this message.
|
|
|
|
|
|
Hi, i got this problem when i retrieve my array
Result = [org.me.sms.Records@71cb25, org.me.sms.Records@cff49f, org.me.sms.Records@c510e3]
how do i retrieve the orignator and text of it?
This is my web service code
@WebMethod(operationName = "RetrieveSMS")
public Records[] RetrieveSMS(@WebParam(name = "username") String username, @WebParam(name = "password") String password, @WebParam(name = "keyword") String keyword) {
ArrayList list = new ArrayList();
ResultSet rs = null;
String statement=null;
try {
Connection conn = null;
Class.forName("oracle.jdbc.driver.OracleDriver");
conn = DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:xe", "smslib", "smslib");
Statement s = conn.createStatement();
statement = "Select * from app_"+keyword;
rs = s.executeQuery(statement);
Records r=null;
while(rs.next())
{
r = new Records();
r.setNumber(rs.getLong("originator"));
r.setText(rs.getString("text"));
list.add(r);
}
s.close();
conn.close();
return (Records[])list.toArray(new Records[list.size()]);
} catch (Exception ex) {
ex.printStackTrace();
}
return null;
}
and my java file
public class Records {
private long number;
private String text;
public long getNumber()
{
return number;
}
public void setNumber(long num)
{
this.number = num;
}
public String getText()
{
return text;
}
public void setText(String text)
{
this.text = text;
}
}
This is my JSP that call the method
<%
try {
org.me.sms.SMSWebServiceService service = new org.me.sms.SMSWebServiceService();
org.me.sms.SMSWebService port = service.getSMSWebServicePort();
java.lang.String username = "";
java.lang.String password = "";
java.lang.String keyword = "Temp";
java.util.List<org.me.sms.Records> result = port.retrieveSMS(username, password, keyword);
out.println("Result = "+result);
} catch (Exception ex) {
}
%>
|
|
|
|
|
|
I do know how to access an array.
But my code does it in a different way.
First it adds my Record object into an arraylist called list and it returns this
return (Records[])list.toArray(new Records[list.size()]);
The above code i took from some tutorial that teach me how to return a database record into a WEB SERVICE method.
In my client index.jsp, i consume the web service with the following code
org.me.sms.SMSWebServiceService service = new org.me.sms.SMSWebServiceService();
org.me.sms.SMSWebService port = service.getSMSWebServicePort();
java.lang.String username = "";
java.lang.String password = "";
java.lang.String keyword = "Temp";
java.util.List<org.me.sms.Records> result = port.retrieveSMS(username, password, keyword);
out.println("Result = "+result);
I could not access the methods in my Records class.
I tried out.println("Result = "+result.getText); but it wont work
|
|
|
|
|
In the above JSP, result is defined as a List. A List is not an array. Even if it was an array, your code wouldn't work the way you seem to expect. Consider the following:
String[] myArray = { "a", "b", "c" };
System.out.println("myArray = " + myArray);
If you know about arrays, you will know that this does not show you the contents of myArray. Try it and see what it does.
I recommend that you read up about arrays and collections.
|
|
|
|
|
I need code for encrypt a any file using .net and decrypt it using java
please any send sample code
Thanks in advance
|
|
|
|
|
Do you have a particular encryption algorithm in mind or is it just a general question? When you say .NET do you mean C#, VB, or do you not care which language? Do you want to roll your own encryption solution or use some sort of framework or toolkit (PGP or similar). Is the file stored on disk in encrypted format for asynchronous access or exchanged over a network synchronously?
As long as you use the same encryption algorithm at both ends (Java and .NET) there is no problem with doing this at all. There are plenty of tutorials on the interweb google thing that show you how to do this for just about every technology under the sun.
|
|
|
|
|
thank Q for replay
i tried to implement a application using AES algorithm, but i did not successed. In .net i am using vb.net
please send me a any sample code to encrypt a file using .net and decrypt it using java
Thank Q
|
|
|
|
|