Buscar
Social
Ofertas laborales ES

Foro sobre Java SE > Qué me conviene para guardar datos de un wav, long o int?

Muchachos como están?... mi cuestion es la del titulo. ¿cual es la más rápida a la hora de reutilizar esos datos?

agosto 18, 2014 | Registered Commenternewstyl3

¿Datos de un wav?. No sé a qué datos te refieres. Si es la longitud del archivo debería ser un long.

agosto 18, 2014 | Registered Commenterchoces

Solamente necesito la longitud, sin el RIFF.

agosto 18, 2014 | Registered Commenternewstyl3

El RIFF estándar de Wave son 44 bytes, por lo que la longitud del archivo debería ser un long, porque un int podría ser demasiado pequeño.

agosto 18, 2014 | Registered Commenterchoces

Estuve chequeando hoy temprano documentación sobre conversion de audio etc, y efectivamente un .WAV tiene un Riff de 44... lo que yo quiero abrir es un wav comprimido en un .KSF que tiene un RIFF de 72 Bytes... Para la lectura de este tipo de archivo cree una clase,, pero me trabe, la parte que serian los "Datos" del wav (vendria a ser el long del que hablamos) cuando abro un archivo .KSF en mi programa se queda en un bucle eterno que nunca termina.. mi idea es tomar esos datos, agregarle el header RIFF del .WAV convirtiendo así el .KSF a wav(guardandolo en una carpeta temporal) para despues convertirlo con la libreria javax.sound.sampled.AudioSystem
a .RAW 8bits....
a ver si me podrás ayudar, te dejo la clase .KSF que cree..

package korg.sample.tool;

import java.io.RandomAccessFile;

class KSF {
private String idSMP1 = null;
private String Chunksize = null;
private String SampleName = null;
/// DefaultBank; < 0... = 8 bytes
private String DefaultBank = null;
private int Start = 0;
private int Start2 = 0;
private String SN01 = null;
private int LoopStart = 0;
private int LoopStart2 = 0;
private String SMD1 = null;
private int Unknown = 0;
private int SampleRate = 0;
private byte Attributes = 0;
private byte LoopTune = 0;
private byte Channels = 0;
private byte BitDepth = 0;
private int SampleSize = 0;
private int[] SamplePoints;

//Sample Waveform reverse compressed

public String getIdSMP1()
{
return this.idSMP1;
}
public void setIdSMP1(String idSMP1)
{
this.idSMP1 = idSMP1;
}
public String getChunkSize()
{
return this.Chunksize;
}
public void setChunkSize(String Chunksize)
{
this.Chunksize = Chunksize;
}
public String getSampleName()
{
return this.SampleName;
}
public void setSampleName(String SampleName)
{
this.SampleName = padString(SampleName, 16);
}
public String getDefaultBank()
{
return this.DefaultBank;
}
public void setDefaultBank(String DefaultBank)
{
this.DefaultBank = DefaultBank;
}
public int getStart()
{
return this.Start;
}
public void setStart (int Start)
{
this.Start = Start;
}
public int getStart2()
{
return this.Start2;
}
public void setStart2(int Start2)
{
this.Start2 = Start2;
}
public String getSN01()
{
return this.SN01;
}
public void setSN01(String SN01)
{
this.SN01 = SN01;
}
public int getLoopStart()
{
return this.LoopStart;
}
public void setLoopStart(int LoopStart)
{
this.LoopStart = LoopStart;
}
public int getLoopStart2()
{
return this.LoopStart2;
}
public void setLoopStart2(int LoopStart2)
{
this.LoopStart2 = LoopStart2;
}
public String getSMD1()
{
return this.SMD1;
}
public void setSMD1(String SMD1)
{
this.SMD1 = SMD1;
}
public int getUnknown()
{
return this.Unknown;
}
public void setUnknown(int Unknown)
{
this.Unknown = Unknown;
}
public int getSampleRate()
{
return this.SampleRate;
}
public void setSampleRate(int SampleRate)
{
this.SampleRate = SampleRate;
}
public byte getAttributes()
{
return this.Attributes;
}
public void setAttributes(byte Attributes)
{
this.Attributes = Attributes;
}
public byte getLoopTune()
{
return this.LoopTune;
}
public void setLoopTune(byte LoopTune)
{
this.LoopTune = LoopTune;
}
public byte getChannels()
{
return this.Channels;
}
public void setChannels(byte Channels)
{
this.Channels = Channels;
}
public byte getBitDepth()
{
return this.BitDepth;
}
public void setBitDepth(byte BitDepth)
{
this.BitDepth = BitDepth;
}
public int getSampleSize()
{
return this.SampleSize;
}
public void setSampleSize(int SampleSize)
{
this.SampleSize = SampleSize;
}
public int[] getSamplePoints()
{
return this.SamplePoints;
}
public void setSamplePoints(int[] SamplePoints)
{
this.SamplePoints = SamplePoints;
}

public int readKSF(String myKsfFile)
{
try
{
RandomAccessFile in = new RandomAccessFile(myKsfFile, "r");

byte[] b = new byte[4];
in.read(b);
String id = new String(b);
if (id.equals("SMP1"))
{
setIdSMP1(id);
}
else
{
setIdSMP1(null);in.close();return 1;
}
in.read(b);
String csz = new String(b);
setChunkSize(csz);

byte[] b1 = new byte[16];
in.read(b1);
setSampleName(new String(b1));

byte[] b2 = new byte[8];
in.read(b2);
String db = new String(b2);
setDefaultBank(db);

int st1 = in.readInt();
setStart(st1);

int st2 = in.readInt();
setStart2(st2);

in.read(b);
String sn = new String(b);
setSN01(sn);

int lpst = in.readInt();
setLoopStart(lpst);

int lpst2 = in.readInt();
setLoopStart2(lpst2);

in.read(b);
String smd = new String(b);
setSMD1(smd);

int unkw = in.readInt();
setUnknown(unkw);

int sprt = in.readInt();
setSampleRate(sprt);

this.Attributes = in.readByte();
this.LoopTune = in.readByte();
this.Channels = in.readByte();
this.BitDepth = in.readByte();

int smpsz = in.readInt();
setSampleSize(smpsz);


in.close();
}
catch (Exception ef)
{
ef.printStackTrace();
}
return 0;
}

public int readKSFSamples(String myKsfFile, int number)
{
try
{
RandomAccessFile in = new RandomAccessFile(myKsfFile, "r");
in.seek(52 + number * 20);


int[] smpp = in.readInt[];
setSamplePoints(smpp);


in.close();

}
catch (Exception ef)
{
System.out.println("Error Reading .KSF Waveform");
return 1;
}
RandomAccessFile in;
return 0;
}

private static String padString(String str, int leng)
{
for (int i = str.length(); i < leng; i++) {
str = str + " ";
}
return str;
}

}

agosto 18, 2014 | Registered Commenternewstyl3

Hasta la parte de "SampleSize " leo el fichero correctamente, el problema viene con lo que sigue que serian los Sample Points... no sé muy bien como declararlo en
"public int readKSFSamples(String myKsfFile, int number)"

agosto 18, 2014 | Registered Commenternewstyl3

Ya pude obtener esos datos como quería :),

agosto 19, 2014 | Registered Commenternewstyl3