addMetadata(metadata, audioFormat.properties()); } catch (UnsupportedAudioFileException e) {
/** * Initializes the encoder with the given source/PCM format. The mp3 * parameters are read from the targetFormat's properties. For any parameter * that is not set, global system properties are queried for backwards * tritonus compatibility. Last, parameters will use the default values * DEFAULT_BITRATE, DEFAULT_CHANNEL_MODE, DEFAULT_QUALITY, and DEFAULT_VBR. * * @throws IllegalArgumentException * when parameters are not supported by LAME. */ public LameEncoder(AudioFormat sourceFormat, AudioFormat targetFormat) { readParams(sourceFormat, targetFormat.properties()); setFormat(sourceFormat, targetFormat); }
@Override public boolean isConversionSupported(AudioFormat.Encoding targetEncoding, AudioFormat sourceFormat){ if (!nativeLibraryLoaded) return false; // because we only support conversions from CAAudioInputStreams we have to check whether the source format // was created by us. All source formats created by us, have the property "provider" set to "casampledsp". if (!CAAudioFormat.CASAMPLEDSP.equals(sourceFormat.properties().get(CAAudioFormat.PROVIDER))) return false; if (super.isConversionSupported(targetEncoding, sourceFormat)) return true; final CAAudioFormat.CAEncoding caEncoding = CAAudioFormat.CAEncoding.getInstance(targetEncoding.toString()); // for now we only decode to signed linear pcm return CAAudioFormat.CAEncoding.PCM_SIGNED.equals(caEncoding); }
@Override public boolean isConversionSupported(final AudioFormat targetFormat, final AudioFormat sourceFormat) { if (!nativeLibraryLoaded) return false; // because we only support conversions from CAAudioInputStreams we have to check whether the source format // was created by us. All source formats created by us, have the property "provider" set to "casampledsp". if (!CAAudioFormat.CASAMPLEDSP.equals(sourceFormat.properties().get(CAAudioFormat.PROVIDER))) return false; if (super.isConversionSupported(targetFormat, sourceFormat)) return true; final CAAudioFormat.CAEncoding caEncoding = CAAudioFormat.CAEncoding.getInstance(targetFormat.getEncoding().toString()); // for now we only decode to signed linear pcm if (!CAAudioFormat.CAEncoding.PCM_SIGNED.equals(caEncoding)) return false; return (targetFormat.getSampleSizeInBits() == 8 || targetFormat.getSampleSizeInBits() == 16 || targetFormat.getSampleSizeInBits() == 24 || targetFormat.getSampleSizeInBits() == 32); }
@Override public AudioFormat[] getTargetFormats(final AudioFormat.Encoding targetEncoding, final AudioFormat sourceFormat) { // make sure we don't try to resample audio with unknown sample rate if (sourceFormat.getSampleRate() == AudioSystem.NOT_SPECIFIED) { return new AudioFormat[0]; } // make an exception for com.tagtraum.casampledsp.CA*** audio formats // they should rather be converted by classes from their own package (taking advantage of native code) if (sourceFormat.getClass().getName().startsWith("com.tagtraum.casampledsp.CA")) { return new AudioFormat[0]; } if (sourceFormat.getEncoding().equals(targetEncoding)) return new AudioFormat[]{ new AudioFormat( sourceFormat.getEncoding(), AudioSystem.NOT_SPECIFIED, sourceFormat.getSampleSizeInBits(), sourceFormat.getChannels(), sourceFormat.getFrameSize(), AudioSystem.NOT_SPECIFIED, sourceFormat.isBigEndian(), sourceFormat.properties() ) }; return new AudioFormat[0]; }
private static AudioFormat toStereoAudioFormat(final AudioFormat monoFormat) { return new AudioFormat( monoFormat.getEncoding(), monoFormat.getSampleRate(), monoFormat.getSampleSizeInBits(), 2, monoFormat.getFrameSize() * 2, monoFormat.getFrameRate(), monoFormat.isBigEndian(), monoFormat.properties() ); }
private static AudioFormat toTargetFormat(final AudioFormat sourceFormat, final int sampleSizeInBits) { // weird conversion to double to avoid numerical problems return new AudioFormat( sourceFormat.getEncoding(), sourceFormat.getSampleRate(), sampleSizeInBits, sourceFormat.getChannels(), (sampleSizeInBits/8)*sourceFormat.getChannels(), sourceFormat.getFrameRate(), sourceFormat.isBigEndian(), sourceFormat.properties() ); }
/** * Create an instance of TAudioFormat as a copy of the supplied audio * format. * * @param format the instance to copy */ public TAudioFormat(AudioFormat format) { this(format.getEncoding(), format.getSampleRate(), format.getSampleSizeInBits(), format.getChannels(), format.getFrameSize(), format.getFrameRate(), format.isBigEndian(), format.properties()); }
/** * Create an instance of TAudioFormat as a copy of the supplied audio * format. * * @param format the instance to copy */ public TAudioFormat(AudioFormat format) { this(format.getEncoding(), format.getSampleRate(), format.getSampleSizeInBits(), format.getChannels(), format.getFrameSize(), format.getFrameRate(), format.isBigEndian(), format.properties()); }
public CAAudioInputStream(final CANativePeerInputStream nativePeerInputStream, final AudioFormat format, final long length) { super(nativePeerInputStream, new AudioFormat( format.getEncoding(), format.getSampleRate(), format.getSampleSizeInBits(), format.getChannels(), format.getFrameSize(), format.getFrameRate(), format.isBigEndian(), createProperties(format.properties()) ), length); this.nativePeerInputStream = nativePeerInputStream; }
public SRCAudioFormat(AudioFormat targetFormat) { super(targetFormat.getEncoding(), targetFormat.getSampleRate(), targetFormat.getSampleSizeInBits(), targetFormat.getChannels(), AudioUtils.getFrameSize( targetFormat.getChannels(), targetFormat.getSampleSizeInBits()), targetFormat.getSampleRate(), targetFormat.isBigEndian(), targetFormat.properties()); this.sampleRate = targetFormat.getSampleRate(); }
private static AudioFormat toTargetFormat(final AudioFormat sourceFormat, final Rational factor) { // weird conversion to double to avoid numerical problems return new AudioFormat( sourceFormat.getEncoding(), (float)(sourceFormat.getSampleRate() * factor.doubleValue()), sourceFormat.getSampleSizeInBits(), sourceFormat.getChannels(), sourceFormat.getFrameSize(), (float)(sourceFormat.getFrameRate() * factor.doubleValue()), sourceFormat.isBigEndian(), sourceFormat.properties() ); }
sourceFormat.getFrameRate(), sourceFormat.isBigEndian(), sourceFormat.properties() ), new AudioFormat( sourceFormat.getFrameRate(), sourceFormat.isBigEndian(), sourceFormat.properties() ), new AudioFormat( sourceFormat.getFrameRate(), sourceFormat.isBigEndian(), sourceFormat.properties() ), new AudioFormat( sourceFormat.getFrameRate(), sourceFormat.isBigEndian(), sourceFormat.properties()
addMetadata(metadata, audioFormat.properties()); } catch (UnsupportedAudioFileException e) {
addMetadata(metadata, audioFormat.properties()); } catch (UnsupportedAudioFileException e) {
targetFormat.getSampleSizeInBits()), sourceStream.getFormat().getFrameRate(), targetFormat.isBigEndian(), targetFormat.properties())); if (TDebug.TraceAudioConverter) { TDebug.out("PCM2PCMStream: constructor. ConversionType=" targetFormat.getSampleSizeInBits()), sourceStream.getFormat().getFrameRate(), targetFormat.isBigEndian(), targetFormat.properties());