protected internal virtual void writeFile(string wavName) { AudioFormat audioFormat = new AudioFormat((float)this.sampleRate, this.bitsPerSample, 1, this.isSigned, true); AudioFileFormat.Type targetType = WavWriter.getTargetType("wav"); byte[] array = this.baos.toByteArray(); ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(array); InputStream inputStream = byteArrayInputStream; AudioFormat audioFormat2 = audioFormat; int num = array.Length; int frameSize = audioFormat.getFrameSize(); AudioInputStream audioInputStream = new AudioInputStream(inputStream, audioFormat2, (long)((frameSize != -1) ? (num / frameSize) : (-(long)num))); File file = new File(wavName); if (AudioSystem.isFileTypeSupported(targetType, audioInputStream)) { try { AudioSystem.write(audioInputStream, targetType, file); } catch (IOException ex) { Throwable.instancehelper_printStackTrace(ex); } } }
public virtual void save(string fileName, AudioFileFormat.Type fileFormat) { File file = new File(fileName); byte[] audio = this.getAudio(); AudioInputStream audioInputStream = new AudioInputStream(new ByteArrayInputStream(audio), this.getAudioFormat(), (long)audio.Length); AudioSystem.write(audioInputStream, fileFormat, file); }
private static AudioFileFormat.Type getTargetType(string text) { AudioFileFormat.Type[] audioFileTypes = AudioSystem.getAudioFileTypes(); AudioFileFormat.Type[] array = audioFileTypes; int num = array.Length; for (int i = 0; i < num; i++) { AudioFileFormat.Type type = array[i]; if (String.instancehelper_equals(type.getExtension(), text)) { return(type); } } return(null); }
/// <summary>Constructs an audio file format object.</summary> /// <remarks> /// Constructs an audio file format object. /// This protected constructor is intended for use by providers of file-reading /// services when returning information about an audio file or about supported audio file /// formats. /// </remarks> /// <param name="type">the type of the audio file</param> /// <param name="byteLength">the length of the file in bytes, or <code>AudioSystem.NOT_SPECIFIED</code> /// </param> /// <param name="format">the format of the audio data contained in the file</param> /// <param name="frameLength">the audio data length in sample frames, or <code>AudioSystem.NOT_SPECIFIED</code> /// </param> /// <seealso cref="getType()">getType()</seealso> protected AudioFileFormat(AudioFileFormat.Type type, int byteLength, AudioFormat format, int frameLength) { // INSTANCE VARIABLES this.type = type; this.byteLength = byteLength; this.format = format; this.frameLength = frameLength; this.propertiesField = null; }