aspose file tools*
The moose likes Other JSE/JEE APIs and the fly likes AudioInputStream contstructor problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "AudioInputStream contstructor problem" Watch "AudioInputStream contstructor problem" New topic
Author

AudioInputStream contstructor problem

Trelan Hylton
Greenhorn

Joined: Apr 15, 2003
Posts: 27
Can anyone help me solve this problem?
This is one of the 2 AudioInputStream constructors:
AudioInputStream(InputStream stream, AudioFormat format, long length)
yet when i try to create an object from this class using the arguments it specifies it says unrecognised method(referring to the constructor)
let me show you:
THIS PROGRAM IS USED TO RETRIEVE A RECORD FROM A DATABASE THAT INCLUDES A SOUND FILE(ACTUALLY A CLIP)

import java.sql.*;
import java.io.*;
import javax.sound.sampled.*;

public class SelectSound {
public static void main(String args[]) {
String url = "jdbc dbc:myDSN";
Connection con;
String createString;
InputStream a;
File f = new File("connect.wav");
Trelan trelan = new Trelan(f);
Statement stmt;
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
} catch(java.lang.ClassNotFoundException e) {
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
try {
con = DriverManager.getConnection(url, "", "");
stmt = con.createStatement();
String query = "SELECT Voice_id, date, sound FROM Recording";
ResultSet rs = stmt.executeQuery(query);
while (rs.next()) {
Object i = rs.getObject("Voice_id");
Date n = rs.getDate("date");
a = rs.getBinaryStream("sound");
Number p = (Number)i;
System.out.println( a+"");
//AudioInputStream audioInput = AudioInputStream(a,trelan.getformat(),trelan.getAudioInputStream().getFrameLength() );
AudioInputStream audioInput = AudioInputStream(a,trelan.audioInputStream.getFormat(),trelan.getAudioInputStream().getFrameLength());
System.out.println( trelan.getAudioInputStream().getFrameLength()+" "+trelan.getformat());
}
stmt.close();
con.close();
} catch(SQLException ex) {
System.err.println("SQLException: " + ex.getMessage());
}
}
}



THIS PROGRAM REPRESENTS THE AUDIOINPUTSTREAM OBJECT

importjava.io.File;
importjava.io.IOException;
importjavax.sound.sampled.*;
public class Trelan{

private Clip m_clip;
AudioFormatformat;
AudioInputStream audioInputStream;
Trelan(File clipFile){
audioInputStream = null;
try
{
audioInputStream = AudioSystem.getAudioInputStream(clipFile);
}
catch (Exception e)
{
e.printStackTrace();
}
if (audioInputStream != null)
{
format = audioInputStream.getFormat();
DataLine.Infoinfo = new DataLine.Info(Clip.class, format);
try
{
m_clip = (Clip) AudioSystem.getLine(info);
//m_clip.addLineListener(this);
//m_clip.open(audioInputStream);
}
catch (LineUnavailableException e)
{
e.printStackTrace();
}

}
}
AudioInputStream getAudioInputStream(){
return audioInputStream;
}
AudioFormat getformat(){
return format;
}
Clip getClip(){
return m_clip;
}
/*public static void main(String[] args)
{
FileclipFile = new File("connect.wav");
Clip clip= new Trelan(clipFile).getClip();
System.out.println("audiofile is "+clip);
//ClipPlayer1clipPlayer = new ClipPlayer1(clipFile, 1);
}
*/
}

What do you think?


JH
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: AudioInputStream contstructor problem