1   package org.daisy.pipeline.audio;
2   
3   import java.io.File;
4   
5   import javax.sound.sampled.AudioFileFormat;
6   import javax.sound.sampled.AudioInputStream;
7   
8   public interface AudioEncoder {
9   
10  	/**
11  	 * Encode raw audio data into a single file (mp3 for instance). This method
12  	 * must forward any exceptions (including InterruptionException).
13  	 *
14  	 * @param pcm is the raw input audio.
15  	 * @param outputFileType the file format the encoder should write in
16  	 * @param outputFile is the output audio file
17  	 * return {@link AudioClip} object to convey a possible offset in the resulting file. Guaranteed
18  	 *        to point to the specified output file and to have the length of the provided audio
19  	 *        stream (apart from any rounding errors due to sampling), but may start at a position
20  	 *        greater than 0.
21  	 * @throws IllegalArgumentException if this decoder does not support <code>outputFileType</code>
22  	 * @throws Throwable when some other error happens
23  	 */
24  	AudioClip encode(AudioInputStream pcm, AudioFileFormat.Type outputFileType, File outputFile) throws Throwable;
25  
26  }