Package edu.harvard.hcl.hclaps.bwav

Examples of edu.harvard.hcl.hclaps.bwav.WAVEFile


   
    return new Document(root);
    }
 
  private Element doWav(Element root, File file) throws FitsToolException {
    WAVEFile wav = null;
    try {
      wav = new WAVEFile(file.getPath());
    }
    catch (FileNotFoundException e) {
      throw new FitsToolException("File "+file.getName() + " not found",e);
    }
   
    Element metadata = new Element("metadata",fitsNS);
    Element audioMetadata = new Element("audio",fitsNS);
   
    Element identification = new Element("identification",fitsNS);
    Element identity = new Element("identity",fitsNS);
    identity.setAttribute("format","Waveform Audio");
    identity.setAttribute("mimetype","audio/x-wave");
    //add identity to identification section
    identification.addContent(identity);
    //add identification section to root
    root.addContent(identification);
   
    Element numSamples = new Element("numSamples",fitsNS);
    numSamples.setText(String.valueOf(wav.dataChunk().getNumberOfSampleFrames()));
    audioMetadata.addContent(numSamples);
           
    Element samplesPerSecond = new Element("sampleRate",fitsNS);
    samplesPerSecond.setText(String.valueOf(wav.formatChunk().getSamplesPerSecond()));
    audioMetadata.addContent(samplesPerSecond)
   
    Element audioDataEncoding = new Element("audioDataEncoding",fitsNS);
    audioDataEncoding.setText(String.valueOf(FormatChunk.FormatTagDescription.getFormatTagDescription(wav.formatChunk().getFormatTag())));
    audioMetadata.addContent(audioDataEncoding)
   
    Element blockAlign = new Element("blockAlign",fitsNS);
    blockAlign.setText(String.valueOf(wav.formatChunk().getBlockAlign()));
    audioMetadata.addContent(blockAlign)
   
    Element time = new Element("time",fitsNS);
    if(wav.bextChunk() != null) {
      time.setText(String.valueOf(wav.bextChunk().getTimeReference()));
    }
    audioMetadata.addContent(time)
   
    Element numChannels = new Element("channels",fitsNS);
    numChannels.setText(String.valueOf(wav.formatChunk().getNumberOfChannels()));
    audioMetadata.addContent(numChannels)
       
    Element bitDepth = new Element("bitDepth",fitsNS);
    bitDepth.setText(String.valueOf(wav.formatChunk().getBitsPerSample()));
    audioMetadata.addContent(bitDepth)
   
    Element wordSize = new Element("wordSize",fitsNS);
    wordSize.setText(String.valueOf(wav.formatChunk().getBlockAlign() / wav.formatChunk().getNumberOfChannels()));
    audioMetadata.addContent(wordSize)
   
    Element offset = new Element("offset",fitsNS);
    offset.setText(Long.toString(wav.dataChunk().getPositionInFile() + 8));
    audioMetadata.addContent(offset)
   
    Element soundField = new Element("soundField",fitsNS);
    if (wav.formatChunk().getNumberOfChannels() == 1) {
      soundField.setText("MONO");
    }
    else if (wav.formatChunk().getNumberOfChannels() == 2) {
      soundField.setText("STEREO");
    }
    else {
      soundField.setText("SURROUND");
    }
View Full Code Here

TOP

Related Classes of edu.harvard.hcl.hclaps.bwav.WAVEFile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.