You can subscribe to this list here.
| 2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
(14) |
Dec
(33) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2002 |
Jan
(68) |
Feb
(19) |
Mar
(6) |
Apr
(97) |
May
(15) |
Jun
(28) |
Jul
(83) |
Aug
(21) |
Sep
(67) |
Oct
(16) |
Nov
|
Dec
(22) |
| 2003 |
Jan
(47) |
Feb
(17) |
Mar
(5) |
Apr
|
May
(5) |
Jun
(106) |
Jul
(25) |
Aug
|
Sep
(14) |
Oct
(7) |
Nov
(24) |
Dec
(5) |
| 2004 |
Jan
(54) |
Feb
(19) |
Mar
|
Apr
(33) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(6) |
Nov
(153) |
Dec
(6) |
| 2005 |
Jan
(178) |
Feb
(17) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2006 |
Jan
(2) |
Feb
(173) |
Mar
|
Apr
(7) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(12) |
Dec
(14) |
| 2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(4) |
Jun
(29) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2008 |
Jan
(29) |
Feb
(3) |
Mar
(5) |
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(4) |
Dec
|
| 2009 |
Jan
|
Feb
|
Mar
(3) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
| 2013 |
Jan
(7) |
Feb
|
Mar
(18) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2015 |
Jan
|
Feb
|
Mar
|
Apr
(7) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Florian B. <fl...@us...> - 2007-06-03 19:36:07
|
Update of /cvsroot/tritonus/tritonus/src/classes/org/tritonus/sampled/convert/lame In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv17425/src/classes/org/tritonus/sampled/convert/lame Modified Files: Mp3LameFormatConversionProvider.java Log Message: pass through of properties to/from low level Lame class, formatted code Direct links to online-CVS: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/tritonus/tritonus/src/classes/org/tritonus/sampled/convert/lame/Mp3LameFormatConversionProvider.java Index: Mp3LameFormatConversionProvider.java =================================================================== RCS file: /cvsroot/tritonus/tritonus/src/classes/org/tritonus/sampled/convert/lame/Mp3LameFormatConversionProvider.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** Mp3LameFormatConversionProvider.java 26 May 2007 14:32:14 -0000 1.3 --- Mp3LameFormatConversionProvider.java 3 Jun 2007 19:36:06 -0000 1.4 *************** *** 24,29 **** /* ! |<--- this code is formatted to fit into 80 columns --->| ! */ package org.tritonus.sampled.convert.lame; --- 24,29 ---- /* ! |<--- this code is formatted to fit into 80 columns --->| ! */ package org.tritonus.sampled.convert.lame; *************** *** 49,221 **** * ConversionProvider for encoding MP3 audio files with the lame lib. * <p> ! * It uses a sloppy implementation of the MPEG1L3 encoding: ! * It is used as a common denominator. So users can always ask for ! * MPEG1L3 encoding but may get in fact an MPEG2L3 or MPEG2.5L3 encoded ! * stream. ! * * @author Florian Bomers */ ! //TODO: - fill frame rate, frame size. Use frame rate for bit rate ? ! // - add decoding ? more work on LAME itself... ! // - byte swapping support in LAME ? ! ! public class Mp3LameFormatConversionProvider ! extends TSimpleFormatConversionProvider { ! ! private static final int ALL=AudioSystem.NOT_SPECIFIED; ! private static final int MPEG_BITS_PER_SAMPLE=ALL; // TODO! should be 0... ! private static final int MPEG_FRAME_RATE=ALL; // TODO @SuppressWarnings("unused") ! private static final int MPEG_FRAME_SIZE=ALL; // TODO ! public static final AudioFormat.Encoding MPEG1L3 = new AudioFormat.Encoding("MPEG1L3"); // Lame converts automagically to MPEG2 or MPEG2.5, if necessary. ! public static final AudioFormat.Encoding MPEG2L3 = new AudioFormat.Encoding("MPEG2L3"); ! public static final AudioFormat.Encoding MPEG2DOT5L3 = new AudioFormat.Encoding("MPEG2DOT5L3"); ! /* ! * Lame provides these formats: ! * MPEG1 layer III samplerates(kHz): 32 44.1 48 ! * bitrates(kbs): 32 40 48 56 64 80 96 112 128 160 192 224 256 320 ! * ! * MPEG2 layer III samplerates(kHz): 16 22.05 24 ! * bitrates(kbs): 8 16 24 32 40 48 56 64 80 96 112 128 144 160 ! * ! * MPEG2.5 layer III samplerates(kHz): 8 11.025 12 ! * bitrates(kbs): 8 16 24 32 40 48 56 64 80 96 112 128 144 160 */ private static final AudioFormat[] OUTPUT_FORMATS = { ! new AudioFormat(MPEG2DOT5L3, 8000, ALL, 1, ALL, ALL, false), ! new AudioFormat(MPEG2DOT5L3, 8000, ALL, 2, ALL, ALL, false), ! new AudioFormat(MPEG2DOT5L3, 8000, ALL, 1, ALL, ALL, true), ! new AudioFormat(MPEG2DOT5L3, 8000, ALL, 2, ALL, ALL, true), ! new AudioFormat(MPEG2DOT5L3, 11025, ALL, 1, ALL, ALL, false), ! new AudioFormat(MPEG2DOT5L3, 11025, ALL, 2, ALL, ALL, false), ! new AudioFormat(MPEG2DOT5L3, 11025, ALL, 1, ALL, ALL, true), ! new AudioFormat(MPEG2DOT5L3, 11025, ALL, 2, ALL, ALL, true), ! new AudioFormat(MPEG2DOT5L3, 12000, ALL, 1, ALL, ALL, false), ! new AudioFormat(MPEG2DOT5L3, 12000, ALL, 2, ALL, ALL, false), ! new AudioFormat(MPEG2DOT5L3, 12000, ALL, 1, ALL, ALL, true), ! new AudioFormat(MPEG2DOT5L3, 12000, ALL, 2, ALL, ALL, true), ! ! new AudioFormat(MPEG2L3, 16000, ALL, 1, ALL, ALL, false), ! new AudioFormat(MPEG2L3, 16000, ALL, 2, ALL, ALL, false), ! new AudioFormat(MPEG2L3, 16000, ALL, 1, ALL, ALL, true), ! new AudioFormat(MPEG2L3, 16000, ALL, 2, ALL, ALL, true), ! new AudioFormat(MPEG2L3, 22050, ALL, 1, ALL, ALL, false), ! new AudioFormat(MPEG2L3, 22050, ALL, 2, ALL, ALL, false), ! new AudioFormat(MPEG2L3, 22050, ALL, 1, ALL, ALL, true), ! new AudioFormat(MPEG2L3, 22050, ALL, 2, ALL, ALL, true), ! new AudioFormat(MPEG2L3, 24000, ALL, 1, ALL, ALL, false), ! new AudioFormat(MPEG2L3, 24000, ALL, 2, ALL, ALL, false), ! new AudioFormat(MPEG2L3, 24000, ALL, 1, ALL, ALL, true), ! new AudioFormat(MPEG2L3, 24000, ALL, 2, ALL, ALL, true), ! ! new AudioFormat(MPEG1L3, 8000, ALL, 1, ALL, ALL, false), //MPEG2DOT5L3 ! new AudioFormat(MPEG1L3, 8000, ALL, 2, ALL, ALL, false), //MPEG2DOT5L3 ! new AudioFormat(MPEG1L3, 8000, ALL, 1, ALL, ALL, true), //MPEG2DOT5L3 ! new AudioFormat(MPEG1L3, 8000, ALL, 2, ALL, ALL, true), //MPEG2DOT5L3 ! new AudioFormat(MPEG1L3, 11025, ALL, 1, ALL, ALL, false),//MPEG2DOT5L3 ! new AudioFormat(MPEG1L3, 11025, ALL, 2, ALL, ALL, false),//MPEG2DOT5L3 ! new AudioFormat(MPEG1L3, 11025, ALL, 1, ALL, ALL, true), //MPEG2DOT5L3 ! new AudioFormat(MPEG1L3, 11025, ALL, 2, ALL, ALL, true), //MPEG2DOT5L3 ! new AudioFormat(MPEG1L3, 12000, ALL, 1, ALL, ALL, false),//MPEG2DOT5L3 ! new AudioFormat(MPEG1L3, 12000, ALL, 2, ALL, ALL, false),//MPEG2DOT5L3 ! new AudioFormat(MPEG1L3, 12000, ALL, 1, ALL, ALL, true), //MPEG2DOT5L3 ! new AudioFormat(MPEG1L3, 12000, ALL, 2, ALL, ALL, true), //MPEG2DOT5L3 ! ! new AudioFormat(MPEG1L3, 16000, ALL, 1, ALL, ALL, false), //MPEG2L3 ! new AudioFormat(MPEG1L3, 16000, ALL, 2, ALL, ALL, false), //MPEG2L3 ! new AudioFormat(MPEG1L3, 16000, ALL, 1, ALL, ALL, true), //MPEG2L3 ! new AudioFormat(MPEG1L3, 16000, ALL, 2, ALL, ALL, true), //MPEG2L3 ! new AudioFormat(MPEG1L3, 22050, ALL, 1, ALL, ALL, false), //MPEG2L3 ! new AudioFormat(MPEG1L3, 22050, ALL, 2, ALL, ALL, false), //MPEG2L3 ! new AudioFormat(MPEG1L3, 22050, ALL, 1, ALL, ALL, true), //MPEG2L3 ! new AudioFormat(MPEG1L3, 22050, ALL, 2, ALL, ALL, true), //MPEG2L3 ! new AudioFormat(MPEG1L3, 24000, ALL, 1, ALL, ALL, false), //MPEG2L3 ! new AudioFormat(MPEG1L3, 24000, ALL, 2, ALL, ALL, false), //MPEG2L3 ! new AudioFormat(MPEG1L3, 24000, ALL, 1, ALL, ALL, true), //MPEG2L3 ! new AudioFormat(MPEG1L3, 24000, ALL, 2, ALL, ALL, true), //MPEG2L3 ! ! new AudioFormat(MPEG1L3, 32000, ALL, 1, ALL, ALL, false), ! new AudioFormat(MPEG1L3, 32000, ALL, 2, ALL, ALL, false), ! new AudioFormat(MPEG1L3, 32000, ALL, 1, ALL, ALL, true), ! new AudioFormat(MPEG1L3, 32000, ALL, 2, ALL, ALL, true), ! new AudioFormat(MPEG1L3, 44100, ALL, 1, ALL, ALL, false), ! new AudioFormat(MPEG1L3, 44100, ALL, 2, ALL, ALL, false), ! new AudioFormat(MPEG1L3, 44100, ALL, 1, ALL, ALL, true), ! new AudioFormat(MPEG1L3, 44100, ALL, 2, ALL, ALL, true), ! new AudioFormat(MPEG1L3, 48000, ALL, 1, ALL, ALL, false), ! new AudioFormat(MPEG1L3, 48000, ALL, 2, ALL, ALL, false), ! new AudioFormat(MPEG1L3, 48000, ALL, 1, ALL, ALL, true), ! new AudioFormat(MPEG1L3, 48000, ALL, 2, ALL, ALL, true), }; private static final AudioFormat[] INPUT_FORMATS = { ! new AudioFormat(8000, 16, 1, true, false), ! new AudioFormat(8000, 16, 1, true, true), ! new AudioFormat(11025, 16, 1, true, false), ! new AudioFormat(11025, 16, 1, true, true), ! new AudioFormat(12000, 16, 1, true, false), ! new AudioFormat(12000, 16, 1, true, true), ! new AudioFormat(16000, 16, 1, true, false), ! new AudioFormat(16000, 16, 1, true, true), ! new AudioFormat(22050, 16, 1, true, false), ! new AudioFormat(22050, 16, 1, true, true), ! new AudioFormat(24000, 16, 1, true, false), ! new AudioFormat(24000, 16, 1, true, true), ! new AudioFormat(32000, 16, 1, true, false), ! new AudioFormat(32000, 16, 1, true, true), ! new AudioFormat(44100, 16, 1, true, false), ! new AudioFormat(44100, 16, 1, true, true), ! new AudioFormat(48000, 16, 1, true, false), ! new AudioFormat(48000, 16, 1, true, true), ! ! new AudioFormat(8000, 16, 2, true, false), ! new AudioFormat(8000, 16, 2, true, true), ! new AudioFormat(11025, 16, 2, true, false), ! new AudioFormat(11025, 16, 2, true, true), ! new AudioFormat(12000, 16, 2, true, false), ! new AudioFormat(12000, 16, 2, true, true), ! new AudioFormat(16000, 16, 2, true, false), ! new AudioFormat(16000, 16, 2, true, true), ! new AudioFormat(22050, 16, 2, true, false), ! new AudioFormat(22050, 16, 2, true, true), ! new AudioFormat(24000, 16, 2, true, false), ! new AudioFormat(24000, 16, 2, true, true), ! new AudioFormat(32000, 16, 2, true, false), ! new AudioFormat(32000, 16, 2, true, true), ! new AudioFormat(44100, 16, 2, true, false), ! new AudioFormat(44100, 16, 2, true, true), ! new AudioFormat(48000, 16, 2, true, false), ! new AudioFormat(48000, 16, 2, true, true), }; - /** * Constructor. */ public Mp3LameFormatConversionProvider() { ! super(Arrays.asList(INPUT_FORMATS), ! Arrays.asList(OUTPUT_FORMATS)); if (!Lame.isLibAvailable()) { disable(); if (TDebug.TraceAudioConverter) { ! TDebug.out("******* Error initializing LAME mp3 encoder: "+Lame.getLinkError()); } } } - public AudioInputStream getAudioInputStream(AudioFormat targetFormat, ! AudioInputStream audioInputStream) { ! if (isConversionSupported(targetFormat, ! audioInputStream.getFormat())) { ! return new EncodedMpegAudioInputStream( ! getDefaultTargetFormat(targetFormat, audioInputStream.getFormat(), false), ! audioInputStream); } else { throw new IllegalArgumentException("conversion not supported"); --- 49,214 ---- * ConversionProvider for encoding MP3 audio files with the lame lib. * <p> ! * It uses a sloppy implementation of the MPEG1L3 encoding: It is used as a ! * common denominator. So users can always ask for MPEG1L3 encoding but may get ! * in fact an MPEG2L3 or MPEG2.5L3 encoded stream. ! * * @author Florian Bomers */ + // TODO: add decoding ? more work on LAME itself... + // TODO: byte swapping support in LAME ? + public class Mp3LameFormatConversionProvider extends + TSimpleFormatConversionProvider { ! private static final int ALL = AudioSystem.NOT_SPECIFIED; ! private static final int MPEG_BITS_PER_SAMPLE = ALL; ! private static final int MPEG_FRAME_RATE = ALL; @SuppressWarnings("unused") ! private static final int MPEG_FRAME_SIZE = ALL; ! public static final AudioFormat.Encoding MPEG1L3 = Lame.MPEG1L3; // Lame converts automagically to MPEG2 or MPEG2.5, if necessary. ! public static final AudioFormat.Encoding MPEG2L3 = Lame.MPEG2L3; ! public static final AudioFormat.Encoding MPEG2DOT5L3 = Lame.MPEG2DOT5L3; ! /** ! * Lame provides these formats:<br> ! * MPEG1 layer III samplerates(kHz): 32 44.1 48<br> ! * bitrates(kbs): 32 40 48 56 64 80 96 112 128 160 192 224 256 320<br> ! * <br> ! * MPEG2 layer III samplerates(kHz): 16 22.05 24<br> ! * bitrates(kbs): 8 16 24 32 40 48 56 64 80 96 112 128 144 160<br> ! * <br> ! * MPEG2.5 layer III samplerates(kHz): 8 11.025 12<br> ! * bitrates(kbs): 8 16 24 32 40 48 56 64 80 96 112 128 144 160<br> */ private static final AudioFormat[] OUTPUT_FORMATS = { ! new AudioFormat(MPEG2DOT5L3, 8000, ALL, 1, ALL, ALL, false), ! new AudioFormat(MPEG2DOT5L3, 8000, ALL, 2, ALL, ALL, false), ! new AudioFormat(MPEG2DOT5L3, 8000, ALL, 1, ALL, ALL, true), ! new AudioFormat(MPEG2DOT5L3, 8000, ALL, 2, ALL, ALL, true), ! new AudioFormat(MPEG2DOT5L3, 11025, ALL, 1, ALL, ALL, false), ! new AudioFormat(MPEG2DOT5L3, 11025, ALL, 2, ALL, ALL, false), ! new AudioFormat(MPEG2DOT5L3, 11025, ALL, 1, ALL, ALL, true), ! new AudioFormat(MPEG2DOT5L3, 11025, ALL, 2, ALL, ALL, true), ! new AudioFormat(MPEG2DOT5L3, 12000, ALL, 1, ALL, ALL, false), ! new AudioFormat(MPEG2DOT5L3, 12000, ALL, 2, ALL, ALL, false), ! new AudioFormat(MPEG2DOT5L3, 12000, ALL, 1, ALL, ALL, true), ! new AudioFormat(MPEG2DOT5L3, 12000, ALL, 2, ALL, ALL, true), ! ! new AudioFormat(MPEG2L3, 16000, ALL, 1, ALL, ALL, false), ! new AudioFormat(MPEG2L3, 16000, ALL, 2, ALL, ALL, false), ! new AudioFormat(MPEG2L3, 16000, ALL, 1, ALL, ALL, true), ! new AudioFormat(MPEG2L3, 16000, ALL, 2, ALL, ALL, true), ! new AudioFormat(MPEG2L3, 22050, ALL, 1, ALL, ALL, false), ! new AudioFormat(MPEG2L3, 22050, ALL, 2, ALL, ALL, false), ! new AudioFormat(MPEG2L3, 22050, ALL, 1, ALL, ALL, true), ! new AudioFormat(MPEG2L3, 22050, ALL, 2, ALL, ALL, true), ! new AudioFormat(MPEG2L3, 24000, ALL, 1, ALL, ALL, false), ! new AudioFormat(MPEG2L3, 24000, ALL, 2, ALL, ALL, false), ! new AudioFormat(MPEG2L3, 24000, ALL, 1, ALL, ALL, true), ! new AudioFormat(MPEG2L3, 24000, ALL, 2, ALL, ALL, true), ! // automagic ! new AudioFormat(MPEG1L3, 8000, ALL, 1, ALL, ALL, false), // MPEG2DOT5L3 ! new AudioFormat(MPEG1L3, 8000, ALL, 2, ALL, ALL, false), // MPEG2DOT5L3 ! new AudioFormat(MPEG1L3, 8000, ALL, 1, ALL, ALL, true), // MPEG2DOT5L3 ! new AudioFormat(MPEG1L3, 8000, ALL, 2, ALL, ALL, true), // MPEG2DOT5L3 ! new AudioFormat(MPEG1L3, 11025, ALL, 1, ALL, ALL, false),// MPEG2DOT5L3 ! new AudioFormat(MPEG1L3, 11025, ALL, 2, ALL, ALL, false),// MPEG2DOT5L3 ! new AudioFormat(MPEG1L3, 11025, ALL, 1, ALL, ALL, true), // MPEG2DOT5L3 ! new AudioFormat(MPEG1L3, 11025, ALL, 2, ALL, ALL, true), // MPEG2DOT5L3 ! new AudioFormat(MPEG1L3, 12000, ALL, 1, ALL, ALL, false),// MPEG2DOT5L3 ! new AudioFormat(MPEG1L3, 12000, ALL, 2, ALL, ALL, false),// MPEG2DOT5L3 ! new AudioFormat(MPEG1L3, 12000, ALL, 1, ALL, ALL, true), // MPEG2DOT5L3 ! new AudioFormat(MPEG1L3, 12000, ALL, 2, ALL, ALL, true), // MPEG2DOT5L3 ! // automagic ! new AudioFormat(MPEG1L3, 16000, ALL, 1, ALL, ALL, false), // MPEG2L3 ! new AudioFormat(MPEG1L3, 16000, ALL, 2, ALL, ALL, false), // MPEG2L3 ! new AudioFormat(MPEG1L3, 16000, ALL, 1, ALL, ALL, true), // MPEG2L3 ! new AudioFormat(MPEG1L3, 16000, ALL, 2, ALL, ALL, true), // MPEG2L3 ! new AudioFormat(MPEG1L3, 22050, ALL, 1, ALL, ALL, false), // MPEG2L3 ! new AudioFormat(MPEG1L3, 22050, ALL, 2, ALL, ALL, false), // MPEG2L3 ! new AudioFormat(MPEG1L3, 22050, ALL, 1, ALL, ALL, true), // MPEG2L3 ! new AudioFormat(MPEG1L3, 22050, ALL, 2, ALL, ALL, true), // MPEG2L3 ! new AudioFormat(MPEG1L3, 24000, ALL, 1, ALL, ALL, false), // MPEG2L3 ! new AudioFormat(MPEG1L3, 24000, ALL, 2, ALL, ALL, false), // MPEG2L3 ! new AudioFormat(MPEG1L3, 24000, ALL, 1, ALL, ALL, true), // MPEG2L3 ! new AudioFormat(MPEG1L3, 24000, ALL, 2, ALL, ALL, true), // MPEG2L3 ! ! new AudioFormat(MPEG1L3, 32000, ALL, 1, ALL, ALL, false), ! new AudioFormat(MPEG1L3, 32000, ALL, 2, ALL, ALL, false), ! new AudioFormat(MPEG1L3, 32000, ALL, 1, ALL, ALL, true), ! new AudioFormat(MPEG1L3, 32000, ALL, 2, ALL, ALL, true), ! new AudioFormat(MPEG1L3, 44100, ALL, 1, ALL, ALL, false), ! new AudioFormat(MPEG1L3, 44100, ALL, 2, ALL, ALL, false), ! new AudioFormat(MPEG1L3, 44100, ALL, 1, ALL, ALL, true), ! new AudioFormat(MPEG1L3, 44100, ALL, 2, ALL, ALL, true), ! new AudioFormat(MPEG1L3, 48000, ALL, 1, ALL, ALL, false), ! new AudioFormat(MPEG1L3, 48000, ALL, 2, ALL, ALL, false), ! new AudioFormat(MPEG1L3, 48000, ALL, 1, ALL, ALL, true), ! new AudioFormat(MPEG1L3, 48000, ALL, 2, ALL, ALL, true), }; private static final AudioFormat[] INPUT_FORMATS = { ! new AudioFormat(8000, 16, 1, true, false), ! new AudioFormat(8000, 16, 1, true, true), ! new AudioFormat(11025, 16, 1, true, false), ! new AudioFormat(11025, 16, 1, true, true), ! new AudioFormat(12000, 16, 1, true, false), ! new AudioFormat(12000, 16, 1, true, true), ! new AudioFormat(16000, 16, 1, true, false), ! new AudioFormat(16000, 16, 1, true, true), ! new AudioFormat(22050, 16, 1, true, false), ! new AudioFormat(22050, 16, 1, true, true), ! new AudioFormat(24000, 16, 1, true, false), ! new AudioFormat(24000, 16, 1, true, true), ! new AudioFormat(32000, 16, 1, true, false), ! new AudioFormat(32000, 16, 1, true, true), ! new AudioFormat(44100, 16, 1, true, false), ! new AudioFormat(44100, 16, 1, true, true), ! new AudioFormat(48000, 16, 1, true, false), ! new AudioFormat(48000, 16, 1, true, true), ! ! new AudioFormat(8000, 16, 2, true, false), ! new AudioFormat(8000, 16, 2, true, true), ! new AudioFormat(11025, 16, 2, true, false), ! new AudioFormat(11025, 16, 2, true, true), ! new AudioFormat(12000, 16, 2, true, false), ! new AudioFormat(12000, 16, 2, true, true), ! new AudioFormat(16000, 16, 2, true, false), ! new AudioFormat(16000, 16, 2, true, true), ! new AudioFormat(22050, 16, 2, true, false), ! new AudioFormat(22050, 16, 2, true, true), ! new AudioFormat(24000, 16, 2, true, false), ! new AudioFormat(24000, 16, 2, true, true), ! new AudioFormat(32000, 16, 2, true, false), ! new AudioFormat(32000, 16, 2, true, true), ! new AudioFormat(44100, 16, 2, true, false), ! new AudioFormat(44100, 16, 2, true, true), ! new AudioFormat(48000, 16, 2, true, false), ! new AudioFormat(48000, 16, 2, true, true), }; /** * Constructor. */ public Mp3LameFormatConversionProvider() { ! super(Arrays.asList(INPUT_FORMATS), Arrays.asList(OUTPUT_FORMATS)); if (!Lame.isLibAvailable()) { disable(); if (TDebug.TraceAudioConverter) { ! TDebug.out("******* Error initializing LAME mp3 encoder: " ! + Lame.getLinkError()); } } } public AudioInputStream getAudioInputStream(AudioFormat targetFormat, ! AudioInputStream audioInputStream) { ! if (isConversionSupported(targetFormat, audioInputStream.getFormat())) { ! return new EncodedMpegAudioInputStream(getDefaultTargetFormat( ! targetFormat, audioInputStream.getFormat(), false), ! audioInputStream); } else { throw new IllegalArgumentException("conversion not supported"); *************** *** 224,228 **** public AudioFormat[] getTargetFormats(AudioFormat.Encoding targetEncoding, ! AudioFormat sourceFormat) { if (TDebug.TraceAudioConverter) { TDebug.out(">MP3Lame getTargetFormats(AudioFormat.Encoding, AudioFormat):"); --- 217,221 ---- public AudioFormat[] getTargetFormats(AudioFormat.Encoding targetEncoding, ! AudioFormat sourceFormat) { if (TDebug.TraceAudioConverter) { TDebug.out(">MP3Lame getTargetFormats(AudioFormat.Encoding, AudioFormat):"); *************** *** 232,261 **** } if (isConversionSupported(targetEncoding, sourceFormat)) { ! AudioFormatSet result=new AudioFormatSet(); ! Iterator iterator=getCollectionTargetFormats().iterator(); while (iterator.hasNext()) { AudioFormat targetFormat = (AudioFormat) iterator.next(); ! //if (TDebug.TraceAudioConverter) { ! //TDebug.out("-checking target format "+targetFormat); ! //} ! if (doMatch(targetFormat.getSampleRate(), sourceFormat.getSampleRate()) ! && targetFormat.getEncoding().equals(targetEncoding) ! && doMatch(targetFormat.getChannels(), sourceFormat.getChannels())) { ! targetFormat=getDefaultTargetFormat(targetFormat, sourceFormat, true); ! //if (TDebug.TraceAudioConverter) { ! //TDebug.out("-yes. added "+targetFormat); ! //} result.add(targetFormat); ! } //else { ! //if (TDebug.TraceAudioConverter) { ! //boolean e=targetFormat.getEncoding().equals(targetEncoding); ! //TDebug.out("-no. \""+targetFormat.getEncoding()+"\"==\""+targetEncoding+"\" ? "+e); ! //} ! //} } - if (TDebug.TraceAudioConverter) { ! TDebug.out("<found "+result.size()+" matching formats."); } return result.toAudioFormatArray(); --- 225,258 ---- } if (isConversionSupported(targetEncoding, sourceFormat)) { ! AudioFormatSet result = new AudioFormatSet(); ! Iterator iterator = getCollectionTargetFormats().iterator(); while (iterator.hasNext()) { AudioFormat targetFormat = (AudioFormat) iterator.next(); ! // if (TDebug.TraceAudioConverter) { ! // TDebug.out("-checking target format "+targetFormat); ! // } ! if (doMatch(targetFormat.getSampleRate(), ! sourceFormat.getSampleRate()) ! && targetFormat.getEncoding().equals(targetEncoding) ! && doMatch(targetFormat.getChannels(), ! sourceFormat.getChannels())) { ! targetFormat = getDefaultTargetFormat(targetFormat, ! sourceFormat, true); ! // if (TDebug.TraceAudioConverter) { ! // TDebug.out("-yes. added "+targetFormat); ! // } result.add(targetFormat); ! } // else { ! // if (TDebug.TraceAudioConverter) { ! // boolean e=targetFormat.getEncoding().equals(targetEncoding); ! // TDebug.out("-no. ! // \""+targetFormat.getEncoding()+"\"==\""+targetEncoding+"\" ? ! // "+e); ! // } ! // } } if (TDebug.TraceAudioConverter) { ! TDebug.out("<found " + result.size() + " matching formats."); } return result.toAudioFormatArray(); *************** *** 269,331 **** protected AudioFormat getDefaultTargetFormat(AudioFormat targetFormat, ! AudioFormat sourceFormat, boolean allowNotSpecified) { // always set bits per sample to MPEG_BITS_PER_SAMPLE // set framerate to MPEG_FRAME_RATE, framesize to FRAME_SIZE ! // always retain sample rate, endianness, ! float targetSampleRate=targetFormat.getSampleRate(); ! if (targetSampleRate==AudioSystem.NOT_SPECIFIED) { ! targetSampleRate=sourceFormat.getSampleRate(); ! } ! if ((!allowNotSpecified && targetSampleRate==AudioSystem.NOT_SPECIFIED) ! || (targetSampleRate!=AudioSystem.NOT_SPECIFIED ! && sourceFormat.getSampleRate()!=AudioSystem.NOT_SPECIFIED ! && targetSampleRate!=sourceFormat.getSampleRate())) { ! throw new IllegalArgumentException("Illegal sample rate ("+targetSampleRate+") !"); ! } ! int targetChannels=targetFormat.getChannels(); ! if (targetChannels==AudioSystem.NOT_SPECIFIED) { ! targetChannels=sourceFormat.getChannels(); ! } ! if ((!allowNotSpecified && targetChannels==AudioSystem.NOT_SPECIFIED) ! || (targetChannels!=AudioSystem.NOT_SPECIFIED ! && sourceFormat.getChannels()!=AudioSystem.NOT_SPECIFIED ! && targetChannels!=sourceFormat.getChannels())) { ! throw new IllegalArgumentException("Illegal number of channels ("+targetChannels+") !"); ! } ! AudioFormat newTargetFormat = new AudioFormat(targetFormat.getEncoding(), ! targetSampleRate, ! MPEG_BITS_PER_SAMPLE, ! targetChannels, ! getFrameSize(targetFormat.getEncoding(), ! targetSampleRate, ! MPEG_BITS_PER_SAMPLE, ! targetChannels, ! MPEG_FRAME_RATE, ! false, ! 0), ! MPEG_FRAME_RATE, ! false); return newTargetFormat; } // implementation from TSimpleFormatConversionProvider ! protected int getFrameSize( ! AudioFormat.Encoding encoding, ! float sampleRate, ! int sampleSize, ! int channels, ! float frameRate, ! boolean bigEndian, ! int oldFrameSize) { if (encoding.equals(AudioFormat.Encoding.PCM_SIGNED) ! || encoding.equals(AudioFormat.Encoding.PCM_UNSIGNED)) { ! return super.getFrameSize( ! encoding, ! sampleRate, ! sampleSize, ! channels, ! frameRate, ! bigEndian, ! oldFrameSize); } // return default frame rate for MPEG --- 266,310 ---- protected AudioFormat getDefaultTargetFormat(AudioFormat targetFormat, ! AudioFormat sourceFormat, boolean allowNotSpecified) { // always set bits per sample to MPEG_BITS_PER_SAMPLE // set framerate to MPEG_FRAME_RATE, framesize to FRAME_SIZE ! // always retain sample rate ! float targetSampleRate = targetFormat.getSampleRate(); ! if (targetSampleRate == AudioSystem.NOT_SPECIFIED) { ! targetSampleRate = sourceFormat.getSampleRate(); ! } ! if ((!allowNotSpecified && targetSampleRate == AudioSystem.NOT_SPECIFIED) ! || (targetSampleRate != AudioSystem.NOT_SPECIFIED ! && sourceFormat.getSampleRate() != AudioSystem.NOT_SPECIFIED && targetSampleRate != sourceFormat.getSampleRate())) { ! throw new IllegalArgumentException("Illegal sample rate (" ! + targetSampleRate + ") !"); ! } ! int targetChannels = targetFormat.getChannels(); ! if (targetChannels == AudioSystem.NOT_SPECIFIED) { ! targetChannels = sourceFormat.getChannels(); ! } ! if ((!allowNotSpecified && targetChannels == AudioSystem.NOT_SPECIFIED) ! || (targetChannels != AudioSystem.NOT_SPECIFIED ! && sourceFormat.getChannels() != AudioSystem.NOT_SPECIFIED && targetChannels != sourceFormat.getChannels())) { ! throw new IllegalArgumentException("Illegal number of channels (" ! + targetChannels + ") !"); ! } ! AudioFormat newTargetFormat = new AudioFormat( ! targetFormat.getEncoding(), targetSampleRate, ! MPEG_BITS_PER_SAMPLE, targetChannels, getFrameSize( ! targetFormat.getEncoding(), targetSampleRate, ! MPEG_BITS_PER_SAMPLE, targetChannels, MPEG_FRAME_RATE, ! false, 0), MPEG_FRAME_RATE, false, targetFormat.properties()); return newTargetFormat; } // implementation from TSimpleFormatConversionProvider ! protected int getFrameSize(AudioFormat.Encoding encoding, float sampleRate, ! int sampleSize, int channels, float frameRate, boolean bigEndian, ! int oldFrameSize) { if (encoding.equals(AudioFormat.Encoding.PCM_SIGNED) ! || encoding.equals(AudioFormat.Encoding.PCM_UNSIGNED)) { ! return super.getFrameSize(encoding, sampleRate, sampleSize, ! channels, frameRate, bigEndian, oldFrameSize); } // return default frame rate for MPEG *************** *** 333,341 **** } ! ! ! public static class EncodedMpegAudioInputStream ! extends TAsynchronousFilteredAudioInputStream ! { private InputStream pcmStream; private Lame encoder; --- 312,317 ---- } ! public static class EncodedMpegAudioInputStream extends ! TAsynchronousFilteredAudioInputStream { private InputStream pcmStream; private Lame encoder; *************** *** 344,358 **** private byte[] encodedBuffer; ! public EncodedMpegAudioInputStream(AudioFormat targetFormat, AudioInputStream sourceStream) { super(targetFormat, -1); pcmStream = sourceStream; ! encoder=new Lame(sourceStream.getFormat()); ! pcmBuffer=new byte[encoder.getPCMBufferSize()]; ! encodedBuffer=new byte[encoder.getMP3BufferSize()]; } public void execute() { try { ! if (encoder==null) { if (TDebug.TraceAudioConverter) { TDebug.out("mp3 lame encoder is null (already at end of stream)"); --- 320,336 ---- private byte[] encodedBuffer; ! public EncodedMpegAudioInputStream(AudioFormat targetFormat, ! AudioInputStream sourceStream) { super(targetFormat, -1); pcmStream = sourceStream; ! encoder = new Lame(sourceStream.getFormat(), targetFormat); ! this.format = encoder.getEffectiveFormat(); ! pcmBuffer = new byte[encoder.getPCMBufferSize()]; ! encodedBuffer = new byte[encoder.getMP3BufferSize()]; } public void execute() { try { ! if (encoder == null) { if (TDebug.TraceAudioConverter) { TDebug.out("mp3 lame encoder is null (already at end of stream)"); *************** *** 361,399 **** return; } ! int encodedBytes=0; ! byte[] buffer=null; ! while (encodedBytes==0 && encoder!=null) { ! int readBytes=pcmStream.read(pcmBuffer); // what to do in case of readBytes==0 ? ! if (readBytes>0) { ! encodedBytes=encoder.encodeBuffer(pcmBuffer, 0, ! readBytes, ! encodedBuffer); ! buffer=encodedBuffer; } else { // take the larger buffer for the remaining frame(s) ! buffer=encodedBuffer.length>pcmBuffer.length?encodedBuffer:pcmBuffer; ! encodedBytes=encoder.encodeFinish(buffer); encoder.close(); ! encoder=null; } } ! if (encodedBytes>0) { getCircularBuffer().write(buffer, 0, encodedBytes); } ! if (encoder==null) { getCircularBuffer().close(); } ! } catch (ArrayIndexOutOfBoundsException e) ! { ! if (TDebug.TraceAudioConverter || TDebug.TraceAllExceptions) ! { TDebug.out(e); } ! } ! catch (IOException e) ! { ! if (TDebug.TraceAudioConverter || TDebug.TraceAllExceptions) ! { TDebug.out(e); } --- 339,372 ---- return; } ! int encodedBytes = 0; ! byte[] buffer = null; ! while (encodedBytes == 0 && encoder != null) { ! int readBytes = pcmStream.read(pcmBuffer); // what to do in case of readBytes==0 ? ! if (readBytes > 0) { ! encodedBytes = encoder.encodeBuffer(pcmBuffer, 0, ! readBytes, encodedBuffer); ! buffer = encodedBuffer; } else { // take the larger buffer for the remaining frame(s) ! buffer = encodedBuffer.length > pcmBuffer.length ? encodedBuffer ! : pcmBuffer; ! encodedBytes = encoder.encodeFinish(buffer); encoder.close(); ! encoder = null; } } ! if (encodedBytes > 0) { getCircularBuffer().write(buffer, 0, encodedBytes); } ! if (encoder == null) { getCircularBuffer().close(); } ! } catch (ArrayIndexOutOfBoundsException e) { ! if (TDebug.TraceAudioConverter || TDebug.TraceAllExceptions) { TDebug.out(e); } ! } catch (IOException e) { ! if (TDebug.TraceAudioConverter || TDebug.TraceAllExceptions) { TDebug.out(e); } *************** *** 401,416 **** } - @SuppressWarnings("unused") - private boolean isBigEndian() { - return getFormat().isBigEndian(); - } - public void close() throws IOException { super.close(); pcmStream.close(); ! if (encoder!=null) { encoder.encodeFinish(null); encoder.close(); ! encoder=null; } } --- 374,384 ---- } public void close() throws IOException { super.close(); pcmStream.close(); ! if (encoder != null) { encoder.encodeFinish(null); encoder.close(); ! encoder = null; } } *************** *** 418,420 **** } ! /*** Mp3LameFormatConversionProvider.java ***/ --- 386,388 ---- } ! /** * Mp3LameFormatConversionProvider.java ** */ |
|
From: Florian B. <fl...@us...> - 2007-06-03 19:33:45
|
Update of /cvsroot/tritonus/tritonus/src/classes/org/tritonus/lowlevel/lame In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv16262/src/classes/org/tritonus/lowlevel/lame Modified Files: Lame.java Log Message: added support for AudioFormat.properties(), formatted code Direct links to online-CVS: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/tritonus/tritonus/src/classes/org/tritonus/lowlevel/lame/Lame.java Index: Lame.java =================================================================== RCS file: /cvsroot/tritonus/tritonus/src/classes/org/tritonus/lowlevel/lame/Lame.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** Lame.java 26 May 2007 14:32:14 -0000 1.4 --- Lame.java 3 Jun 2007 19:33:25 -0000 1.5 *************** *** 6,10 **** /* ! * Copyright (c) 2000,2001 by Florian Bomers <http://www.bomers.de> * * --- 6,10 ---- /* ! * Copyright (c) 2000,2001,2007 by Florian Bomers <http://www.bomers.de> * [...1079 lines suppressed...] try { ! String s = System.getProperty(strPropertyName); ! if (s != null && s.length() > 0) { ! hadSystemProps = true; ! value = new Integer(s).intValue(); ! } ! } catch (Throwable e) { ! if (TDebug.TraceAllExceptions) { TDebug.out(e); } *************** *** 535,538 **** } ! ! /*** Lame.java ***/ --- 712,714 ---- } ! /** * Lame.java ** */ |
|
From: Florian B. <fl...@us...> - 2007-06-03 19:33:44
|
Update of /cvsroot/tritonus/tritonus/src/classes/org/tritonus/sampled/convert In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv16278/src/classes/org/tritonus/sampled/convert Modified Files: LawDecoder.java Log Message: remove compiler warning Direct links to online-CVS: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/tritonus/tritonus/src/classes/org/tritonus/sampled/convert/LawDecoder.java Index: LawDecoder.java =================================================================== RCS file: /cvsroot/tritonus/tritonus/src/classes/org/tritonus/sampled/convert/LawDecoder.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** LawDecoder.java 1 Jun 2007 08:58:08 -0000 1.1 --- LawDecoder.java 3 Jun 2007 19:33:44 -0000 1.2 *************** *** 33,37 **** import java.util.Arrays; - import javax.sound.sampled.AudioSystem; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; --- 33,36 ---- |
|
From: Florian B. <fl...@us...> - 2007-06-01 08:58:08
|
Update of /cvsroot/tritonus/tritonus/src/packaging/tritonus_core/META-INF/services In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv25026/tritonus/src/packaging/tritonus_core/META-INF/services Modified Files: javax.sound.sampled.spi.FormatConversionProvider Log Message: New, fixed and improved aLaw and uLaw codecs Direct links to online-CVS: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/tritonus/tritonus/src/packaging/tritonus_core/META-INF/services/javax.sound.sampled.spi.FormatConversionProvider Index: javax.sound.sampled.spi.FormatConversionProvider =================================================================== RCS file: /cvsroot/tritonus/tritonus/src/packaging/tritonus_core/META-INF/services/javax.sound.sampled.spi.FormatConversionProvider,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -r1.7 -r1.8 *** javax.sound.sampled.spi.FormatConversionProvider 25 Apr 2004 08:55:03 -0000 1.7 --- javax.sound.sampled.spi.FormatConversionProvider 1 Jun 2007 08:58:08 -0000 1.8 *************** *** 2,7 **** # ! org.tritonus.sampled.convert.UlawFormatConversionProvider ! org.tritonus.sampled.convert.AlawFormatConversionProvider org.tritonus.sampled.convert.PCM2PCMConversionProvider #org.tritonus.sampled.convert.SmartFormatConversionProvider --- 2,9 ---- # ! org.tritonus.sampled.convert.LawDecoder ! org.tritonus.sampled.convert.LawEncoder ! #org.tritonus.sampled.convert.UlawFormatConversionProvider ! #org.tritonus.sampled.convert.AlawFormatConversionProvider org.tritonus.sampled.convert.PCM2PCMConversionProvider #org.tritonus.sampled.convert.SmartFormatConversionProvider |
|
From: Florian B. <fl...@us...> - 2007-06-01 08:58:08
|
Update of /cvsroot/tritonus/tritonus/src/classes/org/tritonus/sampled/convert In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv25026/tritonus/src/classes/org/tritonus/sampled/convert Added Files: LawEncoder.java LawDecoder.java Log Message: New, fixed and improved aLaw and uLaw codecs Direct links to online-CVS: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/tritonus/tritonus/src/classes/org/tritonus/sampled/convert/LawEncoder.java http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/tritonus/tritonus/src/classes/org/tritonus/sampled/convert/LawDecoder.java --- NEW FILE: LawEncoder.java --- --- NEW FILE: LawDecoder.java --- |
|
From: Florian B. <fl...@us...> - 2007-06-01 07:17:15
|
Update of /cvsroot/tritonus/tritonus/src/classes/org/tritonus/sampled/convert In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv14933/src/classes/org/tritonus/sampled/convert Modified Files: PCM2PCMConversionProvider.java Log Message: indent and format Direct links to online-CVS: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/tritonus/tritonus/src/classes/org/tritonus/sampled/convert/PCM2PCMConversionProvider.java Index: PCM2PCMConversionProvider.java =================================================================== RCS file: /cvsroot/tritonus/tritonus/src/classes/org/tritonus/sampled/convert/PCM2PCMConversionProvider.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** PCM2PCMConversionProvider.java 25 May 2007 10:59:19 -0000 1.4 --- PCM2PCMConversionProvider.java 1 Jun 2007 07:17:15 -0000 1.5 *************** *** 26,31 **** /* ! |<--- this code is formatted to fit into 80 columns --->| ! */ package org.tritonus.sampled.convert; --- 26,31 ---- /* ! |<--- this code is formatted to fit into 80 columns --->| [...1078 lines suppressed...] if (needExpandChannels) { expandChannels(buffer, byteOffset, frameCount, ! getFormat().getSampleSizeInBits() / 8, ! getFormat().getChannels()); } break; default: throw new RuntimeException( ! "PCM2PCMStream: Call to convertInPlace, but it cannot convert in place."); } } *************** *** 684,686 **** } ! /*** PCM2PCMFormatConversionProvider.java ***/ --- 710,712 ---- } ! /** * PCM2PCMFormatConversionProvider.java ** */ |
|
From: Florian B. <fl...@us...> - 2007-06-01 07:16:28
|
Update of /cvsroot/tritonus/tritonus/src/lib/lame/windows In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv14474/src/lib/lame/windows Modified Files: bladenc.c Log Message: fix quality setting in lametritonus.dll Direct links to online-CVS: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/tritonus/tritonus/src/lib/lame/windows/bladenc.c Index: bladenc.c =================================================================== RCS file: /cvsroot/tritonus/tritonus/src/lib/lame/windows/bladenc.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** bladenc.c 26 Apr 2004 00:35:38 -0000 1.2 --- bladenc.c 1 Jun 2007 07:16:13 -0000 1.3 *************** *** 187,194 **** LONG getBladePreset(int quality) { ! if (quality<org_tritonus_lowlevel_lame_Lame_QUALITY_MIDDLE) { return LQP_LOW_QUALITY; } ! else if (quality>org_tritonus_lowlevel_lame_Lame_QUALITY_MIDDLE) { return LQP_HIGH_QUALITY; } --- 187,194 ---- LONG getBladePreset(int quality) { ! if (quality>org_tritonus_lowlevel_lame_Lame_QUALITY_MIDDLE) { return LQP_LOW_QUALITY; } ! else if (quality<org_tritonus_lowlevel_lame_Lame_QUALITY_MIDDLE) { return LQP_HIGH_QUALITY; } |
|
From: Florian B. <fl...@us...> - 2007-05-26 14:32:21
|
Update of /cvsroot/tritonus/tritonus/src/classes/org/tritonus/lowlevel/lame In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv24061/src/classes/org/tritonus/lowlevel/lame Modified Files: Lame.java Log Message: add annotations to suppress compiler warnings Direct links to online-CVS: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/tritonus/tritonus/src/classes/org/tritonus/lowlevel/lame/Lame.java Index: Lame.java =================================================================== RCS file: /cvsroot/tritonus/tritonus/src/classes/org/tritonus/lowlevel/lame/Lame.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** Lame.java 13 Feb 2006 19:45:30 -0000 1.3 --- Lame.java 26 May 2007 14:32:14 -0000 1.4 *************** *** 41,44 **** --- 41,45 ---- // constants from lame.h private static final int MPEG_VERSION_2 = 0; // MPEG-2 + @SuppressWarnings("unused") // used from native private static final int MPEG_VERSION_1 = 1; // MPEG-1 private static final int MPEG_VERSION_2DOT5 = 2; // MPEG-2.5 *************** *** 104,108 **** * size of ints may be 64 bit. */ ! @SuppressWarnings("unused") private long m_lNativeGlobalFlags; --- 105,109 ---- * size of ints may be 64 bit. */ ! @SuppressWarnings("unused") // used from native private long m_lNativeGlobalFlags; |
|
From: Florian B. <fl...@us...> - 2007-05-26 14:32:21
|
Update of /cvsroot/tritonus/tritonus/src/classes/org/tritonus/sampled/convert/lame In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv24061/src/classes/org/tritonus/sampled/convert/lame Modified Files: Mp3LameFormatConversionProvider.java Log Message: add annotations to suppress compiler warnings Direct links to online-CVS: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/tritonus/tritonus/src/classes/org/tritonus/sampled/convert/lame/Mp3LameFormatConversionProvider.java Index: Mp3LameFormatConversionProvider.java =================================================================== RCS file: /cvsroot/tritonus/tritonus/src/classes/org/tritonus/sampled/convert/lame/Mp3LameFormatConversionProvider.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** Mp3LameFormatConversionProvider.java 13 Feb 2006 12:21:49 -0000 1.2 --- Mp3LameFormatConversionProvider.java 26 May 2007 14:32:14 -0000 1.3 *************** *** 68,71 **** --- 68,72 ---- private static final int MPEG_BITS_PER_SAMPLE=ALL; // TODO! should be 0... private static final int MPEG_FRAME_RATE=ALL; // TODO + @SuppressWarnings("unused") private static final int MPEG_FRAME_SIZE=ALL; // TODO *************** *** 400,403 **** --- 401,405 ---- } + @SuppressWarnings("unused") private boolean isBigEndian() { return getFormat().isBigEndian(); |
|
From: Florian B. <fl...@us...> - 2007-05-26 14:32:21
|
Update of /cvsroot/tritonus/tritonus/src/classes/org/tritonus/share/midi In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv24061/src/classes/org/tritonus/share/midi Modified Files: TSequencer.java TPreloadingSequencer.java Log Message: add annotations to suppress compiler warnings Direct links to online-CVS: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/tritonus/tritonus/src/classes/org/tritonus/share/midi/TSequencer.java http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/tritonus/tritonus/src/classes/org/tritonus/share/midi/TPreloadingSequencer.java Index: TSequencer.java =================================================================== RCS file: /cvsroot/tritonus/tritonus/src/classes/org/tritonus/share/midi/TSequencer.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** TSequencer.java 20 Jan 2005 07:47:16 -0000 1.1 --- TSequencer.java 26 May 2007 14:32:13 -0000 1.2 *************** *** 113,116 **** --- 113,117 ---- /** */ + @SuppressWarnings("unchecked") protected TSequencer(MidiDevice.Info info, Collection<SyncMode> masterSyncModes, Index: TPreloadingSequencer.java =================================================================== RCS file: /cvsroot/tritonus/tritonus/src/classes/org/tritonus/share/midi/TPreloadingSequencer.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** TPreloadingSequencer.java 13 Feb 2006 12:21:50 -0000 1.2 --- TPreloadingSequencer.java 26 May 2007 14:32:13 -0000 1.3 *************** *** 56,59 **** --- 56,60 ---- private int m_nLatency; + @SuppressWarnings("unused") private Thread m_loaderThread; |
|
From: Florian B. <fl...@us...> - 2007-05-25 10:59:24
|
Update of /cvsroot/tritonus/tritonus/src/classes/org/tritonus/sampled/convert In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv18150/tritonus/src/classes/org/tritonus/sampled/convert Modified Files: AlawFormatConversionProvider.java PCM2PCMConversionProvider.java SampleRateConversionProvider.java UlawFormatConversionProvider.java Log Message: use AudioFormat.Encoding.* constants for maximum compatibility. always use AudioFormat.Encoding.equals() instead of comparing the references Direct links to online-CVS: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/tritonus/tritonus/src/classes/org/tritonus/sampled/convert/AlawFormatConversionProvider.java http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/tritonus/tritonus/src/classes/org/tritonus/sampled/convert/PCM2PCMConversionProvider.java http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/tritonus/tritonus/src/classes/org/tritonus/sampled/convert/SampleRateConversionProvider.java http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/tritonus/tritonus/src/classes/org/tritonus/sampled/convert/UlawFormatConversionProvider.java Index: AlawFormatConversionProvider.java =================================================================== RCS file: /cvsroot/tritonus/tritonus/src/classes/org/tritonus/sampled/convert/AlawFormatConversionProvider.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** AlawFormatConversionProvider.java 14 Dec 2006 21:38:11 -0000 1.4 --- AlawFormatConversionProvider.java 25 May 2007 10:59:19 -0000 1.5 *************** *** 6,10 **** /* ! * Copyright (c) 2000 by Florian Bomers <http://www.bomers.de> * * --- 6,10 ---- /* ! * Copyright (c) 2000,2007 by Florian Bomers <http://www.bomers.de> * * *************** *** 61,68 **** private static final int ALL=AudioSystem.NOT_SPECIFIED; ! public static AudioFormat.Encoding ENC_PCM_SIGNED=new AudioFormat.Encoding("PCM_SIGNED"); ! public static AudioFormat.Encoding ENC_PCM_UNSIGNED=new AudioFormat.Encoding("PCM_UNSIGNED"); ! public static AudioFormat.Encoding ENC_ULAW=new AudioFormat.Encoding("ULAW"); ! public static AudioFormat.Encoding ENC_ALAW=new AudioFormat.Encoding("ALAW"); // TODO: --- 61,69 ---- private static final int ALL=AudioSystem.NOT_SPECIFIED; ! // only used as abbreviation ! public static AudioFormat.Encoding ENC_PCM_SIGNED=AudioFormat.Encoding.PCM_SIGNED; ! public static AudioFormat.Encoding ENC_PCM_UNSIGNED=AudioFormat.Encoding.PCM_UNSIGNED; ! public static AudioFormat.Encoding ENC_ULAW=AudioFormat.Encoding.ULAW; ! public static AudioFormat.Encoding ENC_ALAW=AudioFormat.Encoding.ALAW; // TODO: *************** *** 105,110 **** if (doMatch(targetFormat.getFrameRate(), sourceFormat.getFrameRate()) && doMatch(targetFormat.getChannels(), sourceFormat.getChannels())) { if (doMatch(targetFormat.getSampleSizeInBits(),8) ! && targetFormat.getEncoding()==ENC_ALAW) { // OK, the targetFormat seems fine, so we convert it to ALAW // let the remaining checks be done by ToAlawStream --- 106,116 ---- if (doMatch(targetFormat.getFrameRate(), sourceFormat.getFrameRate()) && doMatch(targetFormat.getChannels(), sourceFormat.getChannels())) { + /* + * thanks to Doug Henderson for detecting the use + * of == instead of equals() for comparing the encoding. + * (he's OK with changing the license to BSD) + */ if (doMatch(targetFormat.getSampleSizeInBits(),8) ! && targetFormat.getEncoding().equals(ENC_ALAW)) { // OK, the targetFormat seems fine, so we convert it to ALAW // let the remaining checks be done by ToAlawStream *************** *** 112,116 **** } else if (doMatch(sourceFormat.getSampleSizeInBits(),8) ! && sourceFormat.getEncoding()==ENC_ALAW) { // convert ALAW to the target format return new FromAlawStream(sourceStream, targetFormat); --- 118,122 ---- } else if (doMatch(sourceFormat.getSampleSizeInBits(),8) ! && sourceFormat.getEncoding().equals(ENC_ALAW)) { // convert ALAW to the target format return new FromAlawStream(sourceStream, targetFormat); Index: PCM2PCMConversionProvider.java =================================================================== RCS file: /cvsroot/tritonus/tritonus/src/classes/org/tritonus/sampled/convert/PCM2PCMConversionProvider.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** PCM2PCMConversionProvider.java 14 Dec 2006 21:39:55 -0000 1.3 --- PCM2PCMConversionProvider.java 25 May 2007 10:59:19 -0000 1.4 *************** *** 6,10 **** /* ! * Copyright (c) 2000,2006 by Florian Bomers <http://www.bomers.de> * * --- 6,10 ---- /* ! * Copyright (c) 2000,2006,2007 by Florian Bomers <http://www.bomers.de> * * *************** *** 94,99 **** private static final boolean ONLY_FLOAT_CONVERSION = false; ! public static AudioFormat.Encoding PCM_SIGNED=new AudioFormat.Encoding("PCM_SIGNED"); ! public static AudioFormat.Encoding PCM_UNSIGNED=new AudioFormat.Encoding("PCM_UNSIGNED"); private static final int ALL=AudioSystem.NOT_SPECIFIED; --- 94,100 ---- private static final boolean ONLY_FLOAT_CONVERSION = false; ! // only used as abbreviation ! public static AudioFormat.Encoding PCM_SIGNED=AudioFormat.Encoding.PCM_SIGNED; ! public static AudioFormat.Encoding PCM_UNSIGNED=AudioFormat.Encoding.PCM_UNSIGNED; private static final int ALL=AudioSystem.NOT_SPECIFIED; Index: SampleRateConversionProvider.java =================================================================== RCS file: /cvsroot/tritonus/tritonus/src/classes/org/tritonus/sampled/convert/SampleRateConversionProvider.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -r1.5 -r1.6 *** SampleRateConversionProvider.java 20 Dec 2006 22:16:05 -0000 1.5 --- SampleRateConversionProvider.java 25 May 2007 10:59:19 -0000 1.6 *************** *** 257,261 **** /** Conversion algorithm */ public static final int RESAMPLE=3; ! private boolean eofReached = false; --- 257,261 ---- /** Conversion algorithm */ public static final int RESAMPLE=3; ! private boolean eofReached = false; *************** *** 287,291 **** this.sourceStream=sourceStream; if (sourceStream instanceof FloatSampleInput) { ! sourceInput = (FloatSampleInput) sourceStream; } else { this.sourceInput = null; --- 287,291 ---- this.sourceStream=sourceStream; if (sourceStream instanceof FloatSampleInput) { ! sourceInput = (FloatSampleInput) sourceStream; } else { this.sourceInput = null; *************** *** 305,312 **** // - ignore frame rate totally // - recalculate frame size ! super (new ByteArrayInputStream(new byte[0]), new SRCAudioFormat(targetFormat), ! convertLength(sourceInput.getSampleRate(), ! targetFormat.getSampleRate(), frameLength)); if (TDebug.TraceAudioConverter) { --- 305,312 ---- // - ignore frame rate totally // - recalculate frame size ! super (new ByteArrayInputStream(new byte[0]), new SRCAudioFormat(targetFormat), ! convertLength(sourceInput.getSampleRate(), ! targetFormat.getSampleRate(), frameLength)); if (TDebug.TraceAudioConverter) { *************** *** 325,329 **** } ! /** * Assures that both historyBuffer and working buffer --- 325,329 ---- } ! /** * Assures that both historyBuffer and working buffer *************** *** 526,530 **** while (outSampleOffset < endSampleOffset) { outSamples[outSampleOffset] = inSamples[(int) inSampleOffset]; ! inSampleOffset += increment; outSampleOffset++; --- 526,530 ---- while (outSampleOffset < endSampleOffset) { outSamples[outSampleOffset] = inSamples[(int) inSampleOffset]; ! inSampleOffset += increment; outSampleOffset++; *************** *** 675,684 **** } ! // interface FloatSampleInput ! /* * (non-Javadoc) ! * * @see org.tritonus.share.sampled.FloatSampleInput#getChannels() */ --- 675,684 ---- } ! // interface FloatSampleInput ! /* * (non-Javadoc) ! * * @see org.tritonus.share.sampled.FloatSampleInput#getChannels() */ *************** *** 689,693 **** /* * (non-Javadoc) ! * * @see org.tritonus.share.sampled.FloatSampleInput#getSampleRate() */ --- 689,693 ---- /* * (non-Javadoc) ! * * @see org.tritonus.share.sampled.FloatSampleInput#getSampleRate() */ *************** *** 698,702 **** /* * (non-Javadoc) ! * * @see org.tritonus.share.sampled.FloatSampleInput#isDone() */ --- 698,702 ---- /* * (non-Javadoc) ! * * @see org.tritonus.share.sampled.FloatSampleInput#isDone() */ *************** *** 784,794 **** history=historyBuffer.getChannel(channel); switch (conversionAlgorithm) { ! case SAMPLE_AND_HOLD: convertSampleAndHold2(inSamples, dPos, inSampleCount, increment, ! outSamples, writtenSamples + offset, writeCount, history, historyBuffer.getSampleCount()); break; ! case LINEAR_INTERPOLATION: convertLinearInterpolation2(inSamples, dPos, inSampleCount, increment, ! outSamples, writtenSamples + offset, writeCount, history, historyBuffer.getSampleCount()); break; } --- 784,794 ---- history=historyBuffer.getChannel(channel); switch (conversionAlgorithm) { ! case SAMPLE_AND_HOLD: convertSampleAndHold2(inSamples, dPos, inSampleCount, increment, ! outSamples, writtenSamples + offset, writeCount, history, historyBuffer.getSampleCount()); break; ! case LINEAR_INTERPOLATION: convertLinearInterpolation2(inSamples, dPos, inSampleCount, increment, ! outSamples, writtenSamples + offset, writeCount, history, historyBuffer.getSampleCount()); break; } Index: UlawFormatConversionProvider.java =================================================================== RCS file: /cvsroot/tritonus/tritonus/src/classes/org/tritonus/sampled/convert/UlawFormatConversionProvider.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** UlawFormatConversionProvider.java 14 Dec 2006 21:43:49 -0000 1.4 --- UlawFormatConversionProvider.java 25 May 2007 10:59:19 -0000 1.5 *************** *** 6,10 **** /* ! * Copyright (c) 1999,2000 by Florian Bomers <http://www.bomers.de> * * --- 6,10 ---- /* ! * Copyright (c) 1999,2000,2007 by Florian Bomers <http://www.bomers.de> * * *************** *** 61,68 **** private static final int ALL=AudioSystem.NOT_SPECIFIED; ! public static AudioFormat.Encoding ENC_PCM_SIGNED=new AudioFormat.Encoding("PCM_SIGNED"); ! public static AudioFormat.Encoding ENC_PCM_UNSIGNED=new AudioFormat.Encoding("PCM_UNSIGNED"); ! public static AudioFormat.Encoding ENC_ULAW=new AudioFormat.Encoding("ULAW"); ! public static AudioFormat.Encoding ENC_ALAW=new AudioFormat.Encoding("ALAW"); // TODO: --- 61,69 ---- private static final int ALL=AudioSystem.NOT_SPECIFIED; ! // only used as abbreviation ! public static AudioFormat.Encoding ENC_PCM_SIGNED=AudioFormat.Encoding.PCM_SIGNED; ! public static AudioFormat.Encoding ENC_PCM_UNSIGNED=AudioFormat.Encoding.PCM_UNSIGNED; ! public static AudioFormat.Encoding ENC_ULAW=AudioFormat.Encoding.ULAW; ! public static AudioFormat.Encoding ENC_ALAW=AudioFormat.Encoding.ALAW; // TODO: |
|
From: Florian B. <fl...@us...> - 2006-12-20 22:16:07
|
Update of /cvsroot/tritonus/tritonus/src/classes/org/tritonus/sampled/convert In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv31384/src/classes/org/tritonus/sampled/convert Modified Files: SampleRateConversionProvider.java Log Message: optimized the converters Direct links to online-CVS: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/tritonus/tritonus/src/classes/org/tritonus/sampled/convert/SampleRateConversionProvider.java Index: SampleRateConversionProvider.java =================================================================== RCS file: /cvsroot/tritonus/tritonus/src/classes/org/tritonus/sampled/convert/SampleRateConversionProvider.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -r1.4 -r1.5 *** SampleRateConversionProvider.java 14 Dec 2006 21:43:08 -0000 1.4 --- SampleRateConversionProvider.java 20 Dec 2006 22:16:05 -0000 1.5 *************** *** 345,349 **** // one input buffer block if (bufferSize<outSamples2inSamples(1)) { ! bufferSize=roundUp(outSamples2inSamples(1)); } if (historyBuffer==null) { --- 345,349 ---- // one input buffer block if (bufferSize<outSamples2inSamples(1)) { ! bufferSize=((int) outSamples2inSamples(1)) + 1; } if (historyBuffer==null) { *************** *** 446,463 **** if (!thisBufferValid) { thisBufferValid=true; - //dPos=inc/2; dPos=0.0; } else { ! double temp=dPos; ! dPos-=(double) oldSampleCount; if (DEBUG_STREAM) { TDebug.out("new dPos: "+temp+" - "+oldSampleCount+" = "+dPos); } ! if ((dPos>inc || dPos<-inc) && roundDown(dPos)!=0) { // hard-reset dPos if - why ever - it got out of bounds if (DEBUG_STREAM_PROBLEMS) { ! TDebug.out("Need to hard reset dPos="+dPos+" !!!!!!!!!!!!!!!!!!!!!!!"); } - //dPos=inc/2; dPos=0.0; } --- 446,461 ---- if (!thisBufferValid) { thisBufferValid=true; dPos=0.0; } else { ! double temp = dPos; ! dPos -= (double) oldSampleCount; if (DEBUG_STREAM) { TDebug.out("new dPos: "+temp+" - "+oldSampleCount+" = "+dPos); } ! if ((dPos>inc || dPos<-inc) && ((int) dPos)!=0) { // hard-reset dPos if - why ever - it got out of bounds if (DEBUG_STREAM_PROBLEMS) { ! TDebug.out("Need to hard reset dPos="+dPos+" !"); } dPos=0.0; } *************** *** 465,492 **** } ! private int roundDown(double a) { ! //return a<0?((int) (a-0.5f)):((int) (a+0.5f)); ! //return a<0?(-((int) -a)):((int) a); ! //return (int) a; ! return (int) Math.floor(a); ! } ! ! private int roundUp(double a) { ! //return a<0?((int) (a-0.5f)):((int) (a+0.5f)); ! //return a<0?(-((int) -a)):((int) a); ! return (int) Math.ceil(a); ! } ! ! private void convertSampleAndHold( float[] inSamples, double inSampleOffset, int inSampleCount, double increment, float[] outSamples, int outSampleOffset, int outSampleCount, float[] history, int historyLength) { if (DEBUG_STREAM) { ! TDebug.out("convertSampleAndHold(inSamples["+inSamples.length+"], " ! +roundDown(inSampleOffset)+" to "+roundDown(inSampleOffset+increment*(outSampleCount-1))+", " +"outSamples["+outSamples.length+"], "+outSampleOffset+" to "+(outSampleOffset+outSampleCount-1)+")"); System.out.flush(); } for (int i=0; i<outSampleCount; i++) { ! int iInIndex=roundDown(inSampleOffset+increment*i); if (iInIndex<0) { outSamples[i+outSampleOffset]=history[iInIndex+historyLength]; --- 463,477 ---- } ! protected void convertSampleAndHold1( float[] inSamples, double inSampleOffset, int inSampleCount, double increment, float[] outSamples, int outSampleOffset, int outSampleCount, float[] history, int historyLength) { if (DEBUG_STREAM) { ! TDebug.out("convertSampleAndHold1(inSamples["+inSamples.length+"], " ! +((int) inSampleOffset)+" to "+((int) (inSampleOffset+increment*(outSampleCount-1)))+", " +"outSamples["+outSamples.length+"], "+outSampleOffset+" to "+(outSampleOffset+outSampleCount-1)+")"); System.out.flush(); } for (int i=0; i<outSampleCount; i++) { ! int iInIndex=(int) (inSampleOffset+increment*i); if (iInIndex<0) { outSamples[i+outSampleOffset]=history[iInIndex+historyLength]; *************** *** 507,516 **** } ! private void convertLinearInterpolation( float[] inSamples, double inSampleOffset, int inSampleCount, double increment, float[] outSamples, int outSampleOffset, int outSampleCount, float[] history, int historyLength) { if (DEBUG_STREAM) { ! TDebug.out("convertLinearInterpolate(inSamples["+inSamples.length+"], " ! +roundDown(inSampleOffset)+" to "+roundDown(inSampleOffset+increment*(outSampleCount-1))+", " +"outSamples["+outSamples.length+"], "+outSampleOffset+" to "+(outSampleOffset+outSampleCount-1)+")"); System.out.flush(); --- 492,541 ---- } ! /** ! * optimized version ! * @param inSamples ! * @param inSampleOffset ! * @param inSampleCount ! * @param increment ! * @param outSamples ! * @param outSampleOffset ! * @param outSampleCount ! * @param history ! * @param historyLength ! */ ! private void convertSampleAndHold2( float[] inSamples, double inSampleOffset, int inSampleCount, double increment, float[] outSamples, int outSampleOffset, int outSampleCount, float[] history, int historyLength) { if (DEBUG_STREAM) { ! TDebug.out("convertSampleAndHold2(inSamples["+inSamples.length+"], " ! +((int) inSampleOffset)+" to "+((int) (inSampleOffset+increment*(outSampleCount-1)))+", " ! +"outSamples["+outSamples.length+"], "+outSampleOffset+" to "+(outSampleOffset+outSampleCount-1)+")"); ! System.out.flush(); ! } ! int endSampleOffset = outSampleOffset + outSampleCount; ! // first go through the history ! double dHistoryLength = (double) historyLength; ! while (inSampleOffset < 0.0d && outSampleOffset < endSampleOffset) { ! double dInIndex = (inSampleOffset + dHistoryLength); ! outSamples[outSampleOffset] = history[(int) dInIndex]; ! inSampleOffset += increment; ! outSampleOffset++; ! } ! ! // then go through the remaining new samples ! while (outSampleOffset < endSampleOffset) { ! outSamples[outSampleOffset] = inSamples[(int) inSampleOffset]; ! ! inSampleOffset += increment; ! outSampleOffset++; ! } ! } ! ! protected void convertLinearInterpolation1( ! float[] inSamples, double inSampleOffset, int inSampleCount, double increment, ! float[] outSamples, int outSampleOffset, int outSampleCount, float[] history, int historyLength) { ! if (DEBUG_STREAM) { ! TDebug.out("convertLinearInterpolate1(inSamples["+inSamples.length+"], " ! +((int) inSampleOffset)+" to "+((int) (inSampleOffset+increment*(outSampleCount-1)))+", " +"outSamples["+outSamples.length+"], "+outSampleOffset+" to "+(outSampleOffset+outSampleCount-1)+")"); System.out.flush(); *************** *** 550,554 **** } catch (ArrayIndexOutOfBoundsException aioobe) { if (DEBUG_STREAM_PROBLEMS) { ! TDebug.out("**** REAL INDEX OUT OF BOUNDS ****** outSamples["+i+"]=inSamples[roundDown("+inSampleOffset+")="+roundDown(inSampleOffset)+"];"); } //throw aioobe; --- 575,579 ---- } catch (ArrayIndexOutOfBoundsException aioobe) { if (DEBUG_STREAM_PROBLEMS) { ! TDebug.out("**** REAL INDEX OUT OF BOUNDS ****** outSamples["+i+"]=inSamples[roundDown("+inSampleOffset+")="+((int) inSampleOffset)+"];"); } //throw aioobe; *************** *** 558,561 **** --- 583,670 ---- } + /** + * optimized version of the linear interpolator + * @param inSamples + * @param inSampleOffset + * @param inSampleCount + * @param increment + * @param outSamples + * @param outSampleOffset + * @param outSampleCount + * @param history + * @param historyLength + */ + private void convertLinearInterpolation2(float[] inSamples, + double inSampleOffset, int inSampleCount, double increment, + float[] outSamples, int outSampleOffset, int outSampleCount, + float[] history, int historyLength) { + // cast results: + // (int) -1.7d=-1 (int) -1.5d=-1 (int) -1.2d=-1 (int) -1.0d=-1 (int) + // -0.7d=0 (int) -0.5d=0 (int) -0.2d=0 + if (DEBUG_STREAM) { + TDebug.out("convertLinearInterpolate2(inSamples[" + + inSamples.length + + "], " + +((int) inSampleOffset)+" to "+((int) (inSampleOffset+increment*(outSampleCount-1)))+", " + + "outSamples[" + + outSamples.length + "], " + outSampleOffset + " to " + + (outSampleOffset + outSampleCount - 1) + ")"); + System.out.flush(); + } + + try { + int endSampleOffset = outSampleOffset + outSampleCount; + + // first go through the history + double dHistoryLength = (double) historyLength; + while (inSampleOffset < 0.0d && outSampleOffset < endSampleOffset) { + double dInIndex = (inSampleOffset + dHistoryLength); + int histIndex = (int) dInIndex; + float factor = (float) (dInIndex - histIndex); + + outSamples[outSampleOffset] = (history[histIndex - 1] * (1.0f - factor)) + + (history[histIndex] * factor); + + inSampleOffset += increment; + outSampleOffset++; + } + + // then the transition area: last sample is in history, new sample in inSamples + while (inSampleOffset < 1.0d && outSampleOffset < endSampleOffset) { + float factor = (float) inSampleOffset; + outSamples[outSampleOffset] = (history[historyLength - 1] * (1.0f - factor)) + + (inSamples[0] * factor); + + inSampleOffset += increment; + outSampleOffset++; + } + + // then go through the remaining new samples + while (outSampleOffset < endSampleOffset) { + int iInIndex = (int) inSampleOffset; + float factor = (float) (inSampleOffset - iInIndex); + + outSamples[outSampleOffset] = (inSamples[iInIndex-1] * (1.0f - factor)) + + (inSamples[iInIndex] * factor); + + inSampleOffset += increment; + outSampleOffset++; + } + + } catch (ArrayIndexOutOfBoundsException aioobe) { + if (DEBUG_STREAM_PROBLEMS) { + TDebug.out("**** INDEX OUT OF BOUNDS ****** inSampleOffset=" + + inSampleOffset + + " inSamples.length=" + + inSamples.length + + " outSampleOffset=" + + outSampleOffset + + " outSamples.length=" + + outSamples.length); + } + //throw aioobe; + } + } + private double inSamples2outSamples(double inSamples) { return inSamples*targetSampleRate/sourceSampleRate; *************** *** 633,637 **** // check thisBuffer with samples of source stream int inSampleCount=thisBuffer.getSampleCount(); ! if (roundDown(dPos)>=inSampleCount || !thisBufferValid) { // need to load new data of sourceStream readFromSourceStream(); --- 742,746 ---- // check thisBuffer with samples of source stream int inSampleCount=thisBuffer.getSampleCount(); ! if (((int) dPos) >= inSampleCount || !thisBufferValid) { // need to load new data of sourceStream readFromSourceStream(); *************** *** 644,654 **** int writeCount=count-writtenSamples; // check whether this exceeds the current in-buffer ! if (roundDown(outSamples2inSamples((double) writeCount)+dPos)>=inSampleCount) { ! int lastOutIndex=roundUp(inSamples2outSamples(((double) inSampleCount)-dPos)); // normally, the above formula gives the exact writeCount. // but due to rounding issues, sometimes it has to be decremented once. // so we need to iterate to get the last index and then increment it once to make // it the writeCount (=the number of samples to write) ! while (roundDown(outSamples2inSamples((double) lastOutIndex)+dPos)>=inSampleCount) { lastOutIndex--; if (DEBUG_STREAM) { --- 753,763 ---- int writeCount=count-writtenSamples; // check whether this exceeds the current in-buffer ! if (((int) (outSamples2inSamples((double) writeCount)+dPos))>=inSampleCount) { ! int lastOutIndex=((int) (inSamples2outSamples(((double) inSampleCount)-dPos)))+1; // normally, the above formula gives the exact writeCount. // but due to rounding issues, sometimes it has to be decremented once. // so we need to iterate to get the last index and then increment it once to make // it the writeCount (=the number of samples to write) ! while ((int) (outSamples2inSamples((double) lastOutIndex)+dPos)>=inSampleCount) { lastOutIndex--; if (DEBUG_STREAM) { *************** *** 659,663 **** int testLastOutIndex=writeCount-1; if (DEBUG_STREAM_PROBLEMS) { ! while (roundDown(outSamples2inSamples((double) testLastOutIndex)+dPos)>=inSampleCount) { testLastOutIndex--; } --- 768,772 ---- int testLastOutIndex=writeCount-1; if (DEBUG_STREAM_PROBLEMS) { ! while ((int) (outSamples2inSamples((double) testLastOutIndex)+dPos)>=inSampleCount) { testLastOutIndex--; } *************** *** 675,682 **** history=historyBuffer.getChannel(channel); switch (conversionAlgorithm) { ! case SAMPLE_AND_HOLD: convertSampleAndHold(inSamples, dPos, inSampleCount, increment, ! outSamples, writtenSamples + offset, writeCount, history, historyBuffer.getSampleCount()); break; ! case LINEAR_INTERPOLATION: convertLinearInterpolation(inSamples, dPos, inSampleCount, increment, ! outSamples, writtenSamples + offset, writeCount, history, historyBuffer.getSampleCount()); break; } } --- 784,795 ---- history=historyBuffer.getChannel(channel); switch (conversionAlgorithm) { ! case SAMPLE_AND_HOLD: ! convertSampleAndHold2(inSamples, dPos, inSampleCount, increment, ! outSamples, writtenSamples + offset, writeCount, history, historyBuffer.getSampleCount()); ! break; ! case LINEAR_INTERPOLATION: ! convertLinearInterpolation2(inSamples, dPos, inSampleCount, increment, ! outSamples, writtenSamples + offset, writeCount, history, historyBuffer.getSampleCount()); ! break; } } |
|
From: Florian B. <fl...@us...> - 2006-12-14 21:49:52
|
Update of /cvsroot/tritonus/tritonus/src/classes/org/tritonus/sampled/convert In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv5835/src/classes/org/tritonus/sampled/convert Modified Files: SmartFormatConversionProvider.java ImaAdpcmFormatConversionProvider.java Log Message: remove compiler warnings Direct links to online-CVS: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/tritonus/tritonus/src/classes/org/tritonus/sampled/convert/SmartFormatConversionProvider.java http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/tritonus/tritonus/src/classes/org/tritonus/sampled/convert/ImaAdpcmFormatConversionProvider.java Index: SmartFormatConversionProvider.java =================================================================== RCS file: /cvsroot/tritonus/tritonus/src/classes/org/tritonus/sampled/convert/SmartFormatConversionProvider.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** SmartFormatConversionProvider.java 13 Feb 2006 12:21:49 -0000 1.2 --- SmartFormatConversionProvider.java 14 Dec 2006 21:49:49 -0000 1.3 *************** *** 274,278 **** ! private static boolean isSignedPCM(AudioFormat.Encoding encoding) { return encoding.equals(AudioFormat.Encoding.PCM_SIGNED); --- 274,278 ---- ! protected static boolean isSignedPCM(AudioFormat.Encoding encoding) { return encoding.equals(AudioFormat.Encoding.PCM_SIGNED); Index: ImaAdpcmFormatConversionProvider.java =================================================================== RCS file: /cvsroot/tritonus/tritonus/src/classes/org/tritonus/sampled/convert/ImaAdpcmFormatConversionProvider.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** ImaAdpcmFormatConversionProvider.java 16 Feb 2006 09:14:48 -0000 1.2 --- ImaAdpcmFormatConversionProvider.java 14 Dec 2006 21:49:49 -0000 1.3 *************** *** 338,342 **** /** */ ! private int getSampleSizeInBytes() { return getFormat().getFrameSize() / getFormat().getChannels(); --- 338,342 ---- /** */ ! protected int getSampleSizeInBytes() { return getFormat().getFrameSize() / getFormat().getChannels(); *************** *** 348,352 **** @return . */ ! private int getFrameSize() { return getFormat().getFrameSize(); --- 348,352 ---- @return . */ ! protected int getFrameSize() { return getFormat().getFrameSize(); *************** *** 511,515 **** /** */ ! private int getSampleSizeInBytes() { return getFormat().getFrameSize() / getFormat().getChannels(); --- 511,515 ---- /** */ ! protected int getSampleSizeInBytes() { return getFormat().getFrameSize() / getFormat().getChannels(); *************** *** 521,525 **** @return . */ ! private int getFrameSize() { return getFormat().getFrameSize(); --- 521,525 ---- @return . */ ! protected int getFrameSize() { return getFormat().getFrameSize(); |
|
From: Florian B. <fl...@us...> - 2006-12-14 21:48:57
|
Update of /cvsroot/tritonus/tritonus In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv5422 Modified Files: .cvsignore Log Message: add eclipse build xml file Direct links to online-CVS: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/tritonus/tritonus/.cvsignore Index: .cvsignore =================================================================== RCS file: /cvsroot/tritonus/tritonus/.cvsignore,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -r1.11 -r1.12 *** .cvsignore 19 Apr 2006 15:37:42 -0000 1.11 --- .cvsignore 14 Dec 2006 21:48:56 -0000 1.12 *************** *** 16,17 **** --- 16,18 ---- .project .settings + eclipse_build.xml |
|
From: Florian B. <fl...@us...> - 2006-12-14 21:48:33
|
Update of /cvsroot/tritonus/tritonus/src/classes/org/tritonus/share/sampled/mixer In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv5385/src/classes/org/tritonus/share/sampled/mixer Modified Files: TSoftClip.java TClip.java Log Message: remove compiler warnings Direct links to online-CVS: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/tritonus/tritonus/src/classes/org/tritonus/share/sampled/mixer/TSoftClip.java http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/tritonus/tritonus/src/classes/org/tritonus/share/sampled/mixer/TClip.java Index: TSoftClip.java =================================================================== RCS file: /cvsroot/tritonus/tritonus/src/classes/org/tritonus/share/sampled/mixer/TSoftClip.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** TSoftClip.java 13 Feb 2006 12:21:50 -0000 1.2 --- TSoftClip.java 14 Dec 2006 21:48:30 -0000 1.3 *************** *** 50,58 **** implements Runnable { ! private static final Class[] CONTROL_CLASSES = {/*GainControl.class*/}; private static final int BUFFER_SIZE = 16384; ! private Mixer m_mixer; private SourceDataLine m_line; private byte[] m_abClip; --- 50,60 ---- implements Runnable { ! //$$fb the following field is never used ! //private static final Class[] CONTROL_CLASSES = {/*GainControl.class*/}; private static final int BUFFER_SIZE = 16384; ! //$$fb the following field is never used ! //private Mixer m_mixer; private SourceDataLine m_line; private byte[] m_abClip; *************** *** 69,73 **** */ super(null); ! m_mixer = mixer; DataLine.Info info = new DataLine.Info( SourceDataLine.class, --- 71,75 ---- */ super(null); ! //m_mixer = mixer; DataLine.Info info = new DataLine.Info( SourceDataLine.class, Index: TClip.java =================================================================== RCS file: /cvsroot/tritonus/tritonus/src/classes/org/tritonus/share/sampled/mixer/TClip.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** TClip.java 13 Feb 2006 17:40:07 -0000 1.3 --- TClip.java 14 Dec 2006 21:48:30 -0000 1.4 *************** *** 51,56 **** implements Clip { ! private static final Class[] CONTROL_CLASSES = {/*GainControl.class*/}; ! private static final int BUFFER_FRAMES = 16384; --- 51,57 ---- implements Clip { ! //$$fb the following fields are never used ! //private static final Class[] CONTROL_CLASSES = {/*GainControl.class*/}; ! //private static final int BUFFER_FRAMES = 16384; |
|
From: Florian B. <fl...@us...> - 2006-12-14 21:47:49
|
Update of /cvsroot/tritonus/tritonus/src/classes/org/tritonus/share/sampled/convert In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv4962/src/classes/org/tritonus/share/sampled/convert Modified Files: TSynchronousFilteredAudioInputStream.java Log Message: remove unused method Direct links to online-CVS: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/tritonus/tritonus/src/classes/org/tritonus/share/sampled/convert/TSynchronousFilteredAudioInputStream.java Index: TSynchronousFilteredAudioInputStream.java =================================================================== RCS file: /cvsroot/tritonus/tritonus/src/classes/org/tritonus/share/sampled/convert/TSynchronousFilteredAudioInputStream.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** TSynchronousFilteredAudioInputStream.java 13 Feb 2006 13:25:24 -0000 1.3 --- TSynchronousFilteredAudioInputStream.java 14 Dec 2006 21:47:47 -0000 1.4 *************** *** 260,267 **** - private int getFrameSize() { - return getFormat().getFrameSize(); - } - } --- 260,263 ---- |
|
From: Florian B. <fl...@us...> - 2006-12-14 21:47:22
|
Update of /cvsroot/tritonus/tritonus/src/classes/org/tritonus/share/sampled In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv4913/src/classes/org/tritonus/share/sampled Modified Files: FloatInputStream.java Log Message: better architecture Direct links to online-CVS: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/tritonus/tritonus/src/classes/org/tritonus/share/sampled/FloatInputStream.java Index: FloatInputStream.java =================================================================== RCS file: /cvsroot/tritonus/tritonus/src/classes/org/tritonus/share/sampled/FloatInputStream.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** FloatInputStream.java 29 Nov 2006 12:35:11 -0000 1.1 --- FloatInputStream.java 14 Dec 2006 21:47:16 -0000 1.2 *************** *** 1,322 **** ! /* ! * FloatInputStream.java ! * ! * This file is part of Tritonus: http://www.tritonus.org/ ! */ ! ! /* ! * Copyright (c) 2006 by Florian Bomers <http://www.bomers.de> ! * All rights reserved. ! * ! * Redistribution and use in source and binary forms, with or without ! * modification, are permitted provided that the following conditions ! * are met: ! * ! * - Redistributions of source code must retain the above copyright notice, ! * this list of conditions and the following disclaimer. ! * - Redistributions in binary form must reproduce the above copyright ! * notice, this list of conditions and the following disclaimer in the ! * documentation and/or other materials provided with the distribution. ! * ! * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ! * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ! * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS ! * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ! * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, ! * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ! * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ! * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, ! * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ! * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED ! * OF THE POSSIBILITY OF SUCH DAMAGE. ! */ ! ! /* ! |<--- this code is formatted to fit into 80 columns --->| ! */ ! package org.tritonus.share.sampled; ! ! import java.io.*; ! import javax.sound.sampled.*; ! ! /** ! * An implementation of AudioInputStream that implements the FloatSampleInput ! * interface. This is a convenience class to instantly make any AudioInputStream ! * capable of fulfilling the FloatSampleInput interface, or vice versa: make an ! * existing FloatSampleInput class compatible with AudioInputStream. ! * <p> ! * All calls to FloatSampleInput.read() will cause implicit conversion to ! * FloatSampleBuffer. If the underlying stream implementes FloatSampleInput, the ! * FloatSampleInput.read method is used for reading. ! * ! * @author florian ! */ ! public class FloatInputStream extends AudioInputStream implements ! FloatSampleInput { ! ! // set this if we can read from an AudioInputStream ! private InputStream sourceStream; ! // set this if we can read from an FloatSampleInput ! private FloatSampleInput sourceInput; ! ! /** ! * true if the source stream returned eof, or if this stream was closed. ! */ ! private boolean eofReached = false; ! ! /** ! * a temporary byte buffer for reading from an underlying input stream ! */ ! private byte[] tempBuffer = null; ! ! /** ! * Create a new FloatInputStream that shadows the sourceStream. ! * ! * @param sourceStream ! * @throws IllegalArgumentException if the stream's format is not compatible ! */ ! public FloatInputStream(AudioInputStream sourceStream) { ! super(sourceStream, sourceStream.getFormat(), ! sourceStream.getFrameLength()); ! this.sourceStream = sourceStream; ! init(); ! } ! ! /** ! * Create a new FloatInputStream that shadows the sourceStream. ! * ! * @param sourceStream ! * @param format the native format of sourceStream ! * @param frameLength the length in frames of the streams, or ! * AudioSystem.NOT_SPECIFIED if not known or unlimited. ! * @throws IllegalArgumentException if the stream's format is not compatible ! */ ! public FloatInputStream(InputStream sourceStream, AudioFormat format, ! long frameLength) { ! super(sourceStream, format, frameLength); ! this.sourceStream = sourceStream; ! init(); ! } ! ! /** ! * Create a new FloatInputStream that will make the specified ! * FloatSampleInput a complete AudioInputStream. ! * ! * @param sourceInput ! * @param format the native format for the read(byte[]) method ! * @param frameLength the length in frames of the stream, or ! * AudioSystem.NOT_SPECIFIED if not known or unlimited. ! * @throws IllegalArgumentException if the format is not compatible ! */ ! public FloatInputStream(FloatSampleInput sourceInput, AudioFormat format, ! long frameLength) { ! super(new ByteArrayInputStream(new byte[0]), format, frameLength); ! this.sourceStream = null; ! this.sourceInput = sourceInput; ! init(); ! } ! ! // interface FloatSampleInput ! public void read(FloatSampleBuffer outBuffer) { ! read(outBuffer, 0, outBuffer.getSampleCount()); ! } ! ! private void init() { ! if (sourceStream != null && (sourceStream instanceof FloatSampleInput)) { ! sourceInput = (FloatSampleInput) sourceStream; ! } ! // make sure format is supported, and remember format code ! FloatSampleBuffer.checkFormatSupported(format); ! } ! ! public void read(FloatSampleBuffer buffer, int offset, int sampleCount) { ! if (sampleCount == 0 || isDone()) { ! buffer.setSampleCount(offset, true); ! return; ! } ! if (buffer.getChannelCount() != getChannels()) { ! throw new IllegalArgumentException( ! "read: passed buffer has different channel count"); ! } ! if (sourceInput != null) { ! sourceInput.read(buffer, offset, sampleCount); ! } else { ! // read into temporary byte buffer ! int byteBufferSize = buffer.getSampleCount() ! * getFormat().getFrameSize(); ! if (tempBuffer == null || byteBufferSize > tempBuffer.length) { ! tempBuffer = new byte[byteBufferSize]; ! } ! int readBytes; ! try { ! readBytes = sourceStream.read(tempBuffer, 0, byteBufferSize); ! } catch (IOException ioe) { ! readBytes = -1; ! } ! if (readBytes < 0) { ! eofReached = true; ! readBytes = 0; ! } ! int readSamples = readBytes / getFormat().getFrameSize(); ! buffer.setSampleCount(offset + readSamples, true); ! if (readSamples > 0) { ! // convert ! buffer.setSamplesFromBytes(tempBuffer, 0, getFormat(), offset, ! readSamples); ! } ! } ! } ! ! /* ! * (non-Javadoc) ! * ! * @see org.tritonus.share.sampled.FloatSampleInput#getChannels() ! */ ! public int getChannels() { ! return getFormat().getChannels(); ! } ! ! /* ! * (non-Javadoc) ! * ! * @see org.tritonus.share.sampled.FloatSampleInput#getSampleRate() ! */ ! public float getSampleRate() { ! return getFormat().getSampleRate(); ! } ! ! /* ! * (non-Javadoc) ! * ! * @see org.tritonus.share.sampled.FloatSampleInput#isDone() ! */ ! public boolean isDone() { ! if (!eofReached && sourceInput != null) { ! return sourceInput.isDone(); ! } ! return eofReached; ! } ! ! // interface AudioInputStream ! ! public int read() throws IOException { ! if (getFormat().getFrameSize() != 1) { ! throw new IOException("frame size must be 1 to read a single byte"); ! } ! // very ugly, but efficient. Who uses this method anyway ? ! byte[] temp = new byte[1]; ! int result = read(temp); ! if (result <= 0) { ! return -1; ! } ! return temp[0] & 0xFF; ! } ! ! /** ! * @see #read(byte[], int, int) ! */ ! public int read(byte[] abData) throws IOException { ! return read(abData, 0, abData.length); ! } ! ! private FloatSampleBuffer tempFloatBuffer = null; ! ! /** ! * If an underlying InputStream is available, read from it, otherwise read ! * from an underlying FloatSampleInput stream and convert to a byte array. ! */ ! public int read(byte[] abData, int nOffset, int nLength) throws IOException { ! if (isDone()) { ! return -1; ! } ! // read from sourceStream, if available ! if (sourceStream != null) { ! int readBytes = sourceStream.read(abData, nOffset, nLength); ! if (readBytes < 0) { ! eofReached = true; ! return readBytes; ! } ! } ! // otherwise read from sourceInput ! if (sourceInput.isDone()) { ! return -1; ! } ! int frameCount = nLength / getFormat().getFrameSize(); ! if (tempFloatBuffer == null) { ! tempFloatBuffer = new FloatSampleBuffer(getFormat().getChannels(), ! frameCount, getFormat().getSampleRate()); ! } else { ! tempFloatBuffer.setSampleCount(frameCount, false); ! } ! sourceInput.read(tempFloatBuffer); ! if (abData != null) { ! int writtenBytes = tempFloatBuffer.convertToByteArray(abData, ! nOffset, getFormat()); ! return writtenBytes; ! } ! // special mode: allow abData to be null for skip() ! return frameCount * getFormat().getFrameSize(); ! } ! ! public synchronized long skip(long nSkip) throws IOException { ! // only returns integral frames ! long skipFrames = nSkip / getFormat().getFrameSize(); ! if (sourceStream != null) { ! return sourceStream.skip(skipFrames * getFormat().getFrameSize()); ! } ! // for FloatSampleInput, there is no skip() method, so just read into ! // the tempBuffer ! if (isDone() || skipFrames <= 0) { ! // cannot skip backwards ! return 0; ! } ! return read((byte[]) null, 0, ! (int) (skipFrames * getFormat().getFrameSize())); ! } ! ! public int available() throws IOException { ! if (sourceStream != null) { ! return sourceStream.available(); ! } ! return AudioSystem.NOT_SPECIFIED; ! } ! ! public void mark(int readlimit) { ! if (sourceStream != null) { ! sourceStream.mark(readlimit); ! } else { ! // what to do? ! } ! } ! ! public void reset() throws IOException { ! if (sourceStream != null) { ! sourceStream.reset(); ! } else { ! // what to do? ! } ! } ! ! public boolean markSupported() { ! if (sourceStream != null) { ! return sourceStream.markSupported(); ! } ! return false; ! } ! ! public void close() throws IOException { ! if (eofReached) { ! return; ! } ! eofReached = true; ! if (sourceStream != null) { ! sourceStream.close(); ! } ! // clean memory, this will also be an indicator that ! // the stream is closed ! tempBuffer = null; ! tempFloatBuffer = null; ! } ! ! } --- 1,340 ---- ! /* ! * FloatInputStream.java ! * ! * This file is part of Tritonus: http://www.tritonus.org/ ! */ ! ! /* ! * Copyright (c) 2006 by Florian Bomers <http://www.bomers.de> ! * All rights reserved. ! * ! * Redistribution and use in source and binary forms, with or without ! * modification, are permitted provided that the following conditions ! * are met: ! * ! * - Redistributions of source code must retain the above copyright notice, ! * this list of conditions and the following disclaimer. ! * - Redistributions in binary form must reproduce the above copyright ! * notice, this list of conditions and the following disclaimer in the ! * documentation and/or other materials provided with the distribution. ! * ! * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ! * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT ! * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS ! * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ! * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, ! * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ! * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR ! * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ! * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, ! * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ! * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED ! * OF THE POSSIBILITY OF SUCH DAMAGE. ! */ ! ! /* ! |<--- this code is formatted to fit into 80 columns --->| ! */ ! package org.tritonus.share.sampled; ! ! import java.io.*; ! import javax.sound.sampled.*; ! ! /** ! * An implementation of AudioInputStream that implements the FloatSampleInput ! * interface. This is a convenience class to instantly make any AudioInputStream ! * capable of fulfilling the FloatSampleInput interface, or vice versa: make an ! * existing FloatSampleInput class compatible with AudioInputStream. ! * <p> ! * All calls to FloatSampleInput.read() will cause implicit conversion to ! * FloatSampleBuffer. If the underlying stream implementes FloatSampleInput, the ! * FloatSampleInput.read method is used for reading. ! * ! * @author florian ! */ ! public class FloatInputStream extends AudioInputStream implements ! FloatSampleInput { ! ! // set this if we can read from an AudioInputStream ! private InputStream sourceStream; ! // set this if we can read from an FloatSampleInput ! private FloatSampleInput sourceInput; ! ! /** ! * true if the source stream returned eof, or if this stream was closed. ! */ ! private boolean eofReached = false; ! ! /** ! * a temporary byte buffer for reading from an underlying input stream ! */ ! private byte[] tempBuffer = null; ! ! /** ! * Create a new FloatInputStream that shadows the sourceStream. ! * ! * @param sourceStream ! * @throws IllegalArgumentException if the stream's format is not compatible ! */ ! public FloatInputStream(AudioInputStream sourceStream) { ! super(sourceStream, sourceStream.getFormat(), ! sourceStream.getFrameLength()); ! this.sourceStream = sourceStream; ! init(); ! } ! ! /** ! * Create a new FloatInputStream that shadows the sourceStream. ! * ! * @param sourceStream ! * @param format the native format of sourceStream ! * @param frameLength the length in frames of the streams, or ! * AudioSystem.NOT_SPECIFIED if not known or unlimited. ! * @throws IllegalArgumentException if the stream's format is not compatible ! */ ! public FloatInputStream(InputStream sourceStream, AudioFormat format, ! long frameLength) { ! super(sourceStream, format, frameLength); ! this.sourceStream = sourceStream; ! init(); ! } ! ! /** ! * Create a new FloatInputStream that will make the specified ! * FloatSampleInput a complete AudioInputStream. ! * ! * @param sourceInput ! * @param format the native format for the read(byte[]) method ! * @param frameLength the length in frames of the stream, or ! * AudioSystem.NOT_SPECIFIED if not known or unlimited. ! * @throws IllegalArgumentException if the format is not compatible ! */ ! public FloatInputStream(FloatSampleInput sourceInput, AudioFormat format, ! long frameLength) { ! super(new ByteArrayInputStream(new byte[0]), format, frameLength); ! this.sourceStream = null; ! this.sourceInput = sourceInput; ! init(); ! } ! ! // interface FloatSampleInput ! public void read(FloatSampleBuffer outBuffer) { ! read(outBuffer, 0, outBuffer.getSampleCount()); ! } ! ! private void init() { ! if (sourceStream != null && (sourceStream instanceof FloatSampleInput)) { ! sourceInput = (FloatSampleInput) sourceStream; ! } ! // make sure format is supported, and remember format code ! FloatSampleBuffer.checkFormatSupported(format); ! } ! ! public void read(FloatSampleBuffer buffer, int offset, int sampleCount) { ! if (sampleCount == 0 || isDone()) { ! buffer.setSampleCount(offset, true); ! return; ! } ! if (buffer.getChannelCount() != getChannels()) { ! throw new IllegalArgumentException( ! "read: passed buffer has different channel count"); ! } ! if (sourceInput != null) { ! sourceInput.read(buffer, offset, sampleCount); ! } else { ! // read into temporary byte buffer ! int byteBufferSize = buffer.getSampleCount() ! * getFormat().getFrameSize(); ! if (tempBuffer == null || byteBufferSize > tempBuffer.length) { ! tempBuffer = new byte[byteBufferSize]; ! } ! int readBytes; ! try { ! readBytes = sourceStream.read(tempBuffer, 0, byteBufferSize); ! } catch (IOException ioe) { ! readBytes = -1; ! } ! if (readBytes < 0) { ! eofReached = true; ! readBytes = 0; ! } ! int readSamples = readBytes / getFormat().getFrameSize(); ! buffer.setSampleCount(offset + readSamples, true); ! if (readSamples > 0) { ! // convert ! buffer.setSamplesFromBytes(tempBuffer, 0, getFormat(), offset, ! readSamples); ! } ! } ! } ! ! /* ! * (non-Javadoc) ! * ! * @see org.tritonus.share.sampled.FloatSampleInput#getChannels() ! */ ! public int getChannels() { ! return getFormat().getChannels(); ! } ! ! /* ! * (non-Javadoc) ! * ! * @see org.tritonus.share.sampled.FloatSampleInput#getSampleRate() ! */ ! public float getSampleRate() { ! return getFormat().getSampleRate(); ! } ! ! /* ! * (non-Javadoc) ! * ! * @see org.tritonus.share.sampled.FloatSampleInput#isDone() ! */ ! public boolean isDone() { ! if (!eofReached && sourceInput != null) { ! return sourceInput.isDone(); ! } ! return eofReached; ! } ! ! // interface AudioInputStream ! ! public int read() throws IOException { ! if (getFormat().getFrameSize() != 1) { ! throw new IOException("frame size must be 1 to read a single byte"); ! } ! // very ugly, but efficient. Who uses this method anyway ? ! byte[] temp = new byte[1]; ! int result = read(temp); ! if (result <= 0) { ! return -1; ! } ! return temp[0] & 0xFF; ! } ! ! /** ! * @see #read(byte[], int, int) ! */ ! public int read(byte[] abData) throws IOException { ! return read(abData, 0, abData.length); ! } ! ! private FloatSampleBuffer tempFloatBuffer = null; ! ! /** ! * If an underlying InputStream is available, read from it, otherwise read ! * from an underlying FloatSampleInput stream and convert to a byte array. ! */ ! public int read(byte[] abData, int nOffset, int nLength) throws IOException { ! if (isDone()) { ! return -1; ! } ! // read from sourceStream, if available ! if (sourceStream != null) { ! return readBytesFromInputStream(abData, nOffset,nLength); ! } ! // otherwise read from sourceInput ! return readBytesFromFloatInput(abData, nOffset,nLength); ! } ! ! /** ! * internal method to read from the underlying InputStream.<br> ! * Precondition: sourceStream!=null ! */ ! protected int readBytesFromInputStream(byte[] abData, int nOffset, ! int nLength) throws IOException { ! int readBytes = sourceStream.read(abData, nOffset, nLength); ! if (readBytes < 0) { ! eofReached = true; ! } ! return readBytes; ! } ! ! /** ! * internal method to read from the underlying InputStream.<br> ! * Precondition: sourceInput!=null ! * @param abData: the byte array to fill, or null if just skipping ! */ ! protected int readBytesFromFloatInput(byte[] abData, int nOffset, int nLength) throws IOException { ! if (sourceInput.isDone()) { ! return -1; ! } ! int frameCount = nLength / getFormat().getFrameSize(); ! if (tempFloatBuffer == null) { ! tempFloatBuffer = new FloatSampleBuffer(getFormat().getChannels(), ! frameCount, getFormat().getSampleRate()); ! } else { ! tempFloatBuffer.setSampleCount(frameCount, false); ! } ! sourceInput.read(tempFloatBuffer); ! if (abData != null) { ! int writtenBytes = tempFloatBuffer.convertToByteArray(abData, ! nOffset, getFormat()); ! return writtenBytes; ! } ! // special mode: allow abData to be null for skip() ! return frameCount * getFormat().getFrameSize(); ! } ! ! public synchronized long skip(long nSkip) throws IOException { ! // only returns integral frames ! long skipFrames = nSkip / getFormat().getFrameSize(); ! if (sourceStream != null) { ! return sourceStream.skip(skipFrames * getFormat().getFrameSize()); ! } ! // for FloatSampleInput, there is no skip() method, so just read into ! // the tempBuffer ! if (isDone() || skipFrames <= 0) { ! // cannot skip backwards ! return 0; ! } ! return readBytesFromFloatInput(null, 0, ! (int) (skipFrames * getFormat().getFrameSize())); ! } ! ! public int available() throws IOException { ! if (sourceStream != null) { ! return sourceStream.available(); ! } ! return AudioSystem.NOT_SPECIFIED; ! } ! ! public void mark(int readlimit) { ! if (sourceStream != null) { ! sourceStream.mark(readlimit); ! } else { ! // what to do? ! } ! } ! ! public void reset() throws IOException { ! if (sourceStream != null) { ! sourceStream.reset(); ! } else { ! // what to do? ! } ! } ! ! public boolean markSupported() { ! if (sourceStream != null) { ! return sourceStream.markSupported(); ! } ! return false; ! } ! ! public void close() throws IOException { ! if (eofReached) { ! return; ! } ! eofReached = true; ! if (sourceStream != null) { ! sourceStream.close(); ! } ! // clean memory, this will also be an indicator that ! // the stream is closed ! tempBuffer = null; ! tempFloatBuffer = null; ! } ! ! } |
|
From: Florian B. <fl...@us...> - 2006-12-14 21:46:08
|
Update of /cvsroot/tritonus/tritonus/src/classes/org/tritonus/share/sampled In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv4258/src/classes/org/tritonus/share/sampled Modified Files: AudioFormatSet.java Log Message: add serialVersionUID Direct links to online-CVS: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/tritonus/tritonus/src/classes/org/tritonus/share/sampled/AudioFormatSet.java Index: AudioFormatSet.java =================================================================== RCS file: /cvsroot/tritonus/tritonus/src/classes/org/tritonus/share/sampled/AudioFormatSet.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** AudioFormatSet.java 13 Feb 2006 19:45:32 -0000 1.3 --- AudioFormatSet.java 14 Dec 2006 21:46:03 -0000 1.4 *************** *** 64,67 **** --- 64,69 ---- public class AudioFormatSet extends ArraySet<AudioFormat> { + private static final long serialVersionUID = 1; + protected static final AudioFormat[] EMPTY_FORMAT_ARRAY = new AudioFormat[0]; |
|
From: Florian B. <fl...@us...> - 2006-12-14 21:45:45
|
Update of /cvsroot/tritonus/tritonus/src/classes/org/tritonus/share In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv4057/src/classes/org/tritonus/share Modified Files: StringHashedSet.java TDebug.java Log Message: add serialVersionUID Direct links to online-CVS: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/tritonus/tritonus/src/classes/org/tritonus/share/StringHashedSet.java http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/tritonus/tritonus/src/classes/org/tritonus/share/TDebug.java Index: StringHashedSet.java =================================================================== RCS file: /cvsroot/tritonus/tritonus/src/classes/org/tritonus/share/StringHashedSet.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** StringHashedSet.java 22 Nov 2006 15:43:26 -0000 1.3 --- StringHashedSet.java 14 Dec 2006 21:45:42 -0000 1.4 *************** *** 60,63 **** --- 60,65 ---- public class StringHashedSet<E> extends ArraySet<E> { + private static final long serialVersionUID = 1; + public StringHashedSet() { Index: TDebug.java =================================================================== RCS file: /cvsroot/tritonus/tritonus/src/classes/org/tritonus/share/TDebug.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** TDebug.java 12 Feb 2006 14:07:48 -0000 1.2 --- TDebug.java 14 Dec 2006 21:45:42 -0000 1.3 *************** *** 154,157 **** --- 154,159 ---- extends RuntimeException { + private static final long serialVersionUID = 1; + public AssertException() { |
|
From: Florian B. <fl...@us...> - 2006-12-14 21:45:23
|
Update of /cvsroot/tritonus/tritonus/src/classes/org/tritonus/share In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv4036/src/classes/org/tritonus/share Modified Files: ArraySet.java Log Message: add serialVersionUID Direct links to online-CVS: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/tritonus/tritonus/src/classes/org/tritonus/share/ArraySet.java Index: ArraySet.java =================================================================== RCS file: /cvsroot/tritonus/tritonus/src/classes/org/tritonus/share/ArraySet.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** ArraySet.java 20 Jan 2005 07:47:16 -0000 1.1 --- ArraySet.java 14 Dec 2006 21:45:21 -0000 1.2 *************** *** 41,44 **** --- 41,46 ---- implements Set<E> { + private static final long serialVersionUID = 1; + public ArraySet() { |
|
From: Florian B. <fl...@us...> - 2006-12-14 21:45:00
|
Update of /cvsroot/tritonus/tritonus/src/classes/org/tritonus/sampled/file In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv3618/src/classes/org/tritonus/sampled/file Modified Files: AuAudioFileReader.java Log Message: rudimentary support for properties Direct links to online-CVS: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/tritonus/tritonus/src/classes/org/tritonus/sampled/file/AuAudioFileReader.java Index: AuAudioFileReader.java =================================================================== RCS file: /cvsroot/tritonus/tritonus/src/classes/org/tritonus/sampled/file/AuAudioFileReader.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** AuAudioFileReader.java 13 Feb 2006 19:45:31 -0000 1.3 --- AuAudioFileReader.java 14 Dec 2006 21:44:53 -0000 1.4 *************** *** 36,39 **** --- 36,41 ---- import java.io.IOException; + import java.util.*; + import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioFileFormat; *************** *** 154,160 **** } // skip header information field ! inputStream.skip(nDataOffset - AuTool.DATA_OFFSET); // read header info field ! //String desc=readDescription(dataInputStream, nDataOffset - AuTool.DATA_OFFSET); AudioFormat format = new AudioFormat(encoding, --- 156,167 ---- } // skip header information field ! //inputStream.skip(nDataOffset - AuTool.DATA_OFFSET); // read header info field ! String desc = readDescription(dataInputStream, nDataOffset - AuTool.DATA_OFFSET); ! // add the description to the file format's properties ! Map<String,Object> properties = new HashMap<String, Object>(); ! if (desc!="") { ! properties.put("title", desc); ! } AudioFormat format = new AudioFormat(encoding, *************** *** 171,175 **** AudioSystem.NOT_SPECIFIED:(nDataLength / format.getFrameSize()), (nDataLength==AuTool.AUDIO_UNKNOWN_SIZE)? ! AudioSystem.NOT_SPECIFIED:(nDataLength + nDataOffset)); if (TDebug.TraceAudioFileReader) { TDebug.out("AuAudioFileReader.getAudioFileFormat(InputStream, long): begin"); } return audioFileFormat; --- 178,183 ---- AudioSystem.NOT_SPECIFIED:(nDataLength / format.getFrameSize()), (nDataLength==AuTool.AUDIO_UNKNOWN_SIZE)? ! AudioSystem.NOT_SPECIFIED:(nDataLength + nDataOffset), ! properties); if (TDebug.TraceAudioFileReader) { TDebug.out("AuAudioFileReader.getAudioFileFormat(InputStream, long): begin"); } return audioFileFormat; |
|
From: Florian B. <fl...@us...> - 2006-12-14 21:43:52
|
Update of /cvsroot/tritonus/tritonus/src/classes/org/tritonus/sampled/convert In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv3195/src/classes/org/tritonus/sampled/convert Modified Files: UlawFormatConversionProvider.java Log Message: protected access to isSupportedFormat() Direct links to online-CVS: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/tritonus/tritonus/src/classes/org/tritonus/sampled/convert/UlawFormatConversionProvider.java Index: UlawFormatConversionProvider.java =================================================================== RCS file: /cvsroot/tritonus/tritonus/src/classes/org/tritonus/sampled/convert/UlawFormatConversionProvider.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** UlawFormatConversionProvider.java 16 Feb 2006 09:14:48 -0000 1.3 --- UlawFormatConversionProvider.java 14 Dec 2006 21:43:49 -0000 1.4 *************** *** 132,136 **** private static final int ALAW=5; ! private boolean isSupportedFormat(AudioFormat format) { return getConvertType(format)!=0; } --- 132,136 ---- private static final int ALAW=5; ! protected boolean isSupportedFormat(AudioFormat format) { return getConvertType(format)!=0; } |
|
From: Florian B. <fl...@us...> - 2006-12-14 21:43:13
|
Update of /cvsroot/tritonus/tritonus/src/classes/org/tritonus/sampled/convert In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv3119/src/classes/org/tritonus/sampled/convert Modified Files: SampleRateConversionProvider.java Log Message: make it implement FloatSampleInput interface Direct links to online-CVS: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/tritonus/tritonus/src/classes/org/tritonus/sampled/convert/SampleRateConversionProvider.java Index: SampleRateConversionProvider.java =================================================================== RCS file: /cvsroot/tritonus/tritonus/src/classes/org/tritonus/sampled/convert/SampleRateConversionProvider.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** SampleRateConversionProvider.java 16 Feb 2006 09:14:48 -0000 1.3 --- SampleRateConversionProvider.java 14 Dec 2006 21:43:08 -0000 1.4 *************** *** 6,10 **** /* ! * Copyright (c) 2001 by Florian Bomers <http://www.bomers.de> * * --- 6,10 ---- /* ! * Copyright (c) 2001,2006 by Florian Bomers <http://www.bomers.de> * * *************** *** 31,34 **** --- 31,35 ---- package org.tritonus.sampled.convert; + import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.Arrays; *************** *** 42,45 **** --- 43,47 ---- import org.tritonus.share.sampled.AudioFormats; import org.tritonus.share.sampled.FloatSampleBuffer; + import org.tritonus.share.sampled.FloatSampleInput; import org.tritonus.share.sampled.AudioUtils; import org.tritonus.share.sampled.convert.TSimpleFormatConversionProvider; *************** *** 128,132 **** private static final float[] commonSampleRates={ ! 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000, 64000, 88200, 96000 }; --- 130,134 ---- private static final float[] commonSampleRates={ ! 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000, 56000, 64000, 88200, 96000, 192000 }; *************** *** 207,213 **** } return Math.round(targetFormat.getSampleRate()/sourceFormat.getSampleRate()*sourceLength); - //return (long) (targetFormat.getSampleRate()/sourceFormat.getSampleRate()*sourceLength); } /** --- 209,221 ---- } return Math.round(targetFormat.getSampleRate()/sourceFormat.getSampleRate()*sourceLength); } + protected static long convertLength(float sourceSR, float targetSR, long sourceLength) { + if (sourceLength==AudioSystem.NOT_SPECIFIED) { + return sourceLength; + } + return Math.round(targetSR/sourceSR*sourceLength); + //return (long) (targetFormat.getSampleRate()/sourceFormat.getSampleRate()*sourceLength); + } /** *************** *** 229,233 **** // TODO: when target sample rate is < source sample rate (or only slightly above), // this stream calculates ONE sample too much. ! public static class SampleRateConverterStream extends AudioInputStream { /** the current working buffer with samples of the sourceStream */ --- 237,241 ---- // TODO: when target sample rate is < source sample rate (or only slightly above), // this stream calculates ONE sample too much. ! public static class SampleRateConverterStream extends AudioInputStream implements FloatSampleInput { /** the current working buffer with samples of the sourceStream */ *************** *** 237,242 **** --- 245,252 ---- private byte[] byteBuffer; // used for reading samples of sourceStream private AudioInputStream sourceStream; + private FloatSampleInput sourceInput; private float sourceSampleRate; private float targetSampleRate; + private long sourceFrameLength; /** index in thisBuffer */ private double dPos; *************** *** 247,250 **** --- 257,262 ---- /** Conversion algorithm */ public static final int RESAMPLE=3; + + private boolean eofReached = false; /** source stream is read in buffers of this size - in milliseconds */ *************** *** 274,279 **** --- 286,297 ---- } this.sourceStream=sourceStream; + if (sourceStream instanceof FloatSampleInput) { + sourceInput = (FloatSampleInput) sourceStream; + } else { + this.sourceInput = null; + } sourceSampleRate=sourceStream.getFormat().getSampleRate(); targetSampleRate=targetFormat.getSampleRate(); + sourceFrameLength = sourceStream.getFrameLength(); dPos=0; // use a buffer size of 100ms *************** *** 283,287 **** --- 301,329 ---- } + public SampleRateConverterStream(FloatSampleInput sourceInput, AudioFormat targetFormat, long frameLength) { + // clean up targetFormat: + // - ignore frame rate totally + // - recalculate frame size + super (new ByteArrayInputStream(new byte[0]), + new SRCAudioFormat(targetFormat), + convertLength(sourceInput.getSampleRate(), + targetFormat.getSampleRate(), + frameLength)); + if (TDebug.TraceAudioConverter) { + TDebug.out("SampleRateConverterStream: <init>"); + } + this.sourceStream = null; + this.sourceInput = sourceInput;; + sourceSampleRate = sourceInput.getSampleRate(); + targetSampleRate = targetFormat.getSampleRate(); + sourceFrameLength = frameLength; + dPos=0; + // use a buffer size of 100ms + sourceBufferTime=100; + resizeBuffers(); + flush(); // force read of source stream next time read is called + } + /** * Assures that both historyBuffer and working buffer *************** *** 294,298 **** * may change the size of the buffers. */ ! private synchronized void resizeBuffers() { int bufferSize=(int) AudioUtils.millis2Frames( (long) sourceBufferTime, sourceSampleRate); --- 336,340 ---- * may change the size of the buffers. */ ! private void resizeBuffers() { int bufferSize=(int) AudioUtils.millis2Frames( (long) sourceBufferTime, sourceSampleRate); *************** *** 306,310 **** } if (historyBuffer==null) { ! historyBuffer=new FloatSampleBuffer(sourceStream.getFormat().getChannels(), bufferSize, sourceSampleRate); historyBuffer.makeSilence(); --- 348,352 ---- } if (historyBuffer==null) { ! historyBuffer=new FloatSampleBuffer(getFormat().getChannels(), bufferSize, sourceSampleRate); historyBuffer.makeSilence(); *************** *** 313,317 **** historyBuffer.changeSampleCount(bufferSize, true); if (thisBuffer==null) { ! thisBuffer=new FloatSampleBuffer(sourceStream.getFormat().getChannels(), bufferSize, sourceSampleRate); } --- 355,359 ---- historyBuffer.changeSampleCount(bufferSize, true); if (thisBuffer==null) { ! thisBuffer=new FloatSampleBuffer(getFormat().getChannels(), bufferSize, sourceSampleRate); } *************** *** 324,329 **** * After this method has been called, it is to be checked whether * we are closed ! */ ! private synchronized void readFromByteSourceStream() throws IOException { int byteCount=thisBuffer.getByteArrayBufferSize(getFormat()); if (byteBuffer==null || byteBuffer.length<byteCount) { --- 366,372 ---- * After this method has been called, it is to be checked whether * we are closed ! + * Precondition: sourceStream!=null */ ! private void readFromByteSourceStream() { int byteCount=thisBuffer.getByteArrayBufferSize(getFormat()); if (byteBuffer==null || byteBuffer.length<byteCount) { *************** *** 334,342 **** int thisRead; do { ! thisRead=sourceStream.read(byteBuffer, bytesRead, byteCount-bytesRead); ! if (thisRead>0) { ! bytesRead+=thisRead; } ! } while (bytesRead<byteCount && thisRead>0); if (bytesRead==0) { // sourceStream is closed. We don't accept 0 bytes read from source stream --- 377,390 ---- int thisRead; do { ! try { ! thisRead = sourceStream.read(byteBuffer, bytesRead, ! byteCount - bytesRead); ! } catch (IOException ioe) { ! thisRead = -1; ! } ! if (thisRead > 0) { ! bytesRead += thisRead; } ! } while (bytesRead < byteCount && thisRead > 0); if (bytesRead==0) { // sourceStream is closed. We don't accept 0 bytes read from source stream *************** *** 347,352 **** } ! private synchronized void readFromFloatSourceStream() throws IOException { ! //((FloatSampleInput) sourceStream).read(thisBuffer); } --- 395,404 ---- } ! /** pre-condition: sourceInput != null */ ! private void readFromSourceInput() { ! sourceInput.read(thisBuffer); ! if (sourceInput.isDone()) { ! close(); ! } } *************** *** 362,366 **** * of <code>thisBuffer</code> are not valid. */ ! private synchronized void readFromSourceStream() throws IOException { if (isClosed()) { return; --- 414,418 ---- * of <code>thisBuffer</code> are not valid. */ ! private void readFromSourceStream() { if (isClosed()) { return; *************** *** 371,388 **** historyBuffer=thisBuffer; thisBuffer=newBuffer; ! if (sourceStream.getFrameLength()!=AudioSystem.NOT_SPECIFIED ! && thisBuffer.getSampleCount()+testInFramesRead>sourceStream.getFrameLength()) { ! if (sourceStream.getFrameLength()-testInFramesRead<=0) { close(); return; } ! thisBuffer.changeSampleCount((int) (sourceStream.getFrameLength()-testInFramesRead), false); } ! // if (sourceStream instanceof FloatSampleInput) { ! // readFromFloatSourceStream(); ! // } else { readFromByteSourceStream(); ! // } if (TDebug.TraceAudioConverter) { testInFramesRead+=thisBuffer.getSampleCount(); --- 423,440 ---- historyBuffer=thisBuffer; thisBuffer=newBuffer; ! if (sourceFrameLength!=AudioSystem.NOT_SPECIFIED ! && thisBuffer.getSampleCount()+testInFramesRead>sourceFrameLength) { ! if (sourceFrameLength-testInFramesRead<=0) { close(); return; } ! thisBuffer.changeSampleCount((int) (sourceFrameLength-testInFramesRead), false); } ! if (sourceInput != null) { ! readFromSourceInput(); ! } else { readFromByteSourceStream(); ! } if (TDebug.TraceAudioConverter) { testInFramesRead+=thisBuffer.getSampleCount(); *************** *** 514,517 **** --- 566,603 ---- } + + // interface FloatSampleInput + + /* + * (non-Javadoc) + * + * @see org.tritonus.share.sampled.FloatSampleInput#getChannels() + */ + public int getChannels() { + return getFormat().getChannels(); + } + + /* + * (non-Javadoc) + * + * @see org.tritonus.share.sampled.FloatSampleInput#getSampleRate() + */ + public float getSampleRate() { + return getFormat().getSampleRate(); + } + + /* + * (non-Javadoc) + * + * @see org.tritonus.share.sampled.FloatSampleInput#isDone() + */ + public boolean isDone() { + return isClosed(); + } + + public void read(FloatSampleBuffer outBuffer) { + read(outBuffer, 0, outBuffer.getSampleCount()); + } + /** * Main read method. It blocks until all samples are converted or *************** *** 520,524 **** * the current setting of <code>conversionAlgorithm</code>. * At most outBuffer.getSampleCount() are converted. In general, ! * if the return value (and outBuffer.getSampleCount()) is less * after processing this function, then it is an indicator * that it was the last block to be processed. --- 606,610 ---- * the current setting of <code>conversionAlgorithm</code>. * At most outBuffer.getSampleCount() are converted. In general, ! * if outBuffer.getSampleCount()) is less * after processing this function, then it is an indicator * that it was the last block to be processed. *************** *** 527,545 **** * @param outBuffer the buffer that the converted samples will be written to. * @throws IllegalArgumentException when outBuffer's channel count does not match - * @return number of samples in outBuffer ( == outBuffer.getSampleCount()) - * or -1. A return value of 0 is only possible when outBuffer has 0 samples. */ ! public synchronized int read(FloatSampleBuffer outBuffer) throws IOException { ! if (isClosed()) { ! return -1; } if (outBuffer.getChannelCount()!=thisBuffer.getChannelCount()) { throw new IllegalArgumentException("passed buffer has different channel count"); } - if (outBuffer.getSampleCount()==0) { - return 0; - } if (TDebug.TraceAudioConverter) { ! TDebug.out(">SamplerateConverterStream.read("+outBuffer.getSampleCount()+"frames)"); } float[] outSamples; --- 613,627 ---- * @param outBuffer the buffer that the converted samples will be written to. * @throws IllegalArgumentException when outBuffer's channel count does not match */ ! public void read(FloatSampleBuffer outBuffer, int offset, int count) { ! if (isClosed() || count == 0) { ! outBuffer.setSampleCount(offset, true); ! return; } if (outBuffer.getChannelCount()!=thisBuffer.getChannelCount()) { throw new IllegalArgumentException("passed buffer has different channel count"); } if (TDebug.TraceAudioConverter) { ! TDebug.out(">SamplerateConverterStream.read("+count+" samples)"); } float[] outSamples; *************** *** 560,564 **** } // calculate number of samples to write ! int writeCount=outBuffer.getSampleCount()-writtenSamples; // check whether this exceeds the current in-buffer if (roundDown(outSamples2inSamples((double) writeCount)+dPos)>=inSampleCount) { --- 642,646 ---- } // calculate number of samples to write ! int writeCount=count-writtenSamples; // check whether this exceeds the current in-buffer if (roundDown(outSamples2inSamples((double) writeCount)+dPos)>=inSampleCount) { *************** *** 594,600 **** switch (conversionAlgorithm) { case SAMPLE_AND_HOLD: convertSampleAndHold(inSamples, dPos, inSampleCount, increment, ! outSamples, writtenSamples, writeCount, history, historyBuffer.getSampleCount()); break; case LINEAR_INTERPOLATION: convertLinearInterpolation(inSamples, dPos, inSampleCount, increment, ! outSamples, writtenSamples, writeCount, history, historyBuffer.getSampleCount()); break; } } --- 676,682 ---- switch (conversionAlgorithm) { case SAMPLE_AND_HOLD: convertSampleAndHold(inSamples, dPos, inSampleCount, increment, ! outSamples, writtenSamples + offset, writeCount, history, historyBuffer.getSampleCount()); break; case LINEAR_INTERPOLATION: convertLinearInterpolation(inSamples, dPos, inSampleCount, increment, ! outSamples, writtenSamples + offset, writeCount, history, historyBuffer.getSampleCount()); break; } } *************** *** 603,608 **** dPos+=outSamples2inSamples((double) writeCount); } while (!isClosed() && writtenSamples<outBuffer.getSampleCount()); ! if (writtenSamples<outBuffer.getSampleCount()) { ! outBuffer.changeSampleCount(writtenSamples, true); } if (TDebug.TraceAudioConverter) { --- 685,690 ---- dPos+=outSamples2inSamples((double) writeCount); } while (!isClosed() && writtenSamples<outBuffer.getSampleCount()); ! if (writtenSamples<count) { ! outBuffer.changeSampleCount(writtenSamples+offset, true); } if (TDebug.TraceAudioConverter) { *************** *** 610,614 **** TDebug.out("< return "+outBuffer.getSampleCount()+"frames. Total="+testOutFramesReturned+" frames. Read total "+testInFramesRead+" frames from source stream"); } - return outBuffer.getSampleCount(); } --- 692,695 ---- *************** *** 641,645 **** public int getSourceFrameSize() { ! return sourceStream.getFormat().getFrameSize(); } --- 722,726 ---- public int getSourceFrameSize() { ! return sourceStream!=null?sourceStream.getFormat().getFrameSize():1; } *************** *** 683,688 **** writeBuffer.changeSampleCount(frameCount, false); } ! int writtenSamples=read(writeBuffer); ! if (writtenSamples==-1) { return -1; } --- 764,769 ---- writeBuffer.changeSampleCount(frameCount, false); } ! read(writeBuffer); ! if (eofReached) { return -1; } *************** *** 694,698 **** // only returns integral frames long sourceSkip = targetBytes2sourceBytes(nSkip); ! long sourceSkipped = sourceStream.skip(sourceSkip); flush(); return sourceBytes2targetBytes(sourceSkipped); --- 775,779 ---- // only returns integral frames long sourceSkip = targetBytes2sourceBytes(nSkip); ! long sourceSkipped = sourceStream!=null?sourceStream.skip(sourceSkip):0; flush(); return sourceBytes2targetBytes(sourceSkipped); *************** *** 701,704 **** --- 782,788 ---- public int available() throws IOException { + if (sourceStream==null) { + return -1; + } return (int) sourceBytes2targetBytes(sourceStream.available()); } *************** *** 706,726 **** public void mark(int readlimit) { ! sourceStream.mark((int) targetBytes2sourceBytes(readlimit)); } public synchronized void reset() throws IOException { ! sourceStream.reset(); ! flush(); } public boolean markSupported() { ! return sourceStream.markSupported(); } ! public void close() throws IOException { if (isClosed()) { return; } ! sourceStream.close(); // clean memory, this will also be an indicator that // the stream is closed --- 790,823 ---- public void mark(int readlimit) { ! if (sourceStream!=null) { ! sourceStream.mark((int) targetBytes2sourceBytes(readlimit)); ! } } public synchronized void reset() throws IOException { ! if (sourceStream!=null) { ! sourceStream.reset(); ! flush(); ! } } public boolean markSupported() { ! if (sourceStream!=null) { ! return sourceStream.markSupported(); ! } ! return false; } ! public void close() { if (isClosed()) { return; } ! if (sourceStream != null) { ! try { ! sourceStream.close(); ! } catch (IOException ioe) { ! } ! } ! eofReached = true; // clean memory, this will also be an indicator that // the stream is closed *************** *** 733,737 **** public boolean isClosed() { ! return thisBuffer==null; } --- 830,834 ---- public boolean isClosed() { ! return eofReached || (thisBuffer==null); } |
|
From: Florian B. <fl...@us...> - 2006-12-14 21:40:01
|
Update of /cvsroot/tritonus/tritonus/src/classes/org/tritonus/sampled/convert In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv1439/src/classes/org/tritonus/sampled/convert Modified Files: PCM2PCMConversionProvider.java Log Message: remove unused format codes Direct links to online-CVS: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/tritonus/tritonus/src/classes/org/tritonus/sampled/convert/PCM2PCMConversionProvider.java Index: PCM2PCMConversionProvider.java =================================================================== RCS file: /cvsroot/tritonus/tritonus/src/classes/org/tritonus/sampled/convert/PCM2PCMConversionProvider.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** PCM2PCMConversionProvider.java 16 Feb 2006 09:14:48 -0000 1.2 --- PCM2PCMConversionProvider.java 14 Dec 2006 21:39:55 -0000 1.3 *************** *** 6,10 **** /* ! * Copyright (c) 2000 by Florian Bomers <http://www.bomers.de> * * --- 6,10 ---- /* ! * Copyright (c) 2000,2006 by Florian Bomers <http://www.bomers.de> * * *************** *** 176,180 **** } return new PCM2PCMStream(sourceStream, targetFormat, ! sourceType, targetType, conversionType); } --- 176,180 ---- } return new PCM2PCMStream(sourceStream, targetFormat, ! conversionType); } *************** *** 403,408 **** class PCM2PCMStream extends TSynchronousFilteredAudioInputStream { private int conversionType; - private int sourceType; - private int targetType; private boolean needExpandChannels; private boolean needMixDown; --- 403,406 ---- *************** *** 412,416 **** public PCM2PCMStream(AudioInputStream sourceStream, AudioFormat targetFormat, ! int sourceType, int targetType, int conversionType) { // transform the targetFormat so that // FrameRate, and SampleRate match the sourceFormat --- 410,414 ---- public PCM2PCMStream(AudioInputStream sourceStream, AudioFormat targetFormat, ! int conversionType) { // transform the targetFormat so that // FrameRate, and SampleRate match the sourceFormat *************** *** 428,433 **** } this.conversionType=conversionType; - this.sourceType=sourceType; - this.targetType=targetType; needExpandChannels=sourceStream.getFormat().getChannels()<targetFormat.getChannels(); needMixDown=sourceStream.getFormat().getChannels()>targetFormat.getChannels(); --- 426,429 ---- |
|
From: Florian B. <fl...@us...> - 2006-12-14 21:38:17
|
Update of /cvsroot/tritonus/tritonus/src/classes/org/tritonus/sampled/convert In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv959/src/classes/org/tritonus/sampled/convert Modified Files: AlawFormatConversionProvider.java Log Message: protected access to isSupportedFormat() Direct links to online-CVS: http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/tritonus/tritonus/src/classes/org/tritonus/sampled/convert/AlawFormatConversionProvider.java Index: AlawFormatConversionProvider.java =================================================================== RCS file: /cvsroot/tritonus/tritonus/src/classes/org/tritonus/sampled/convert/AlawFormatConversionProvider.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** AlawFormatConversionProvider.java 16 Feb 2006 09:14:48 -0000 1.3 --- AlawFormatConversionProvider.java 14 Dec 2006 21:38:11 -0000 1.4 *************** *** 126,130 **** private static final int ULAW=5; ! private boolean isSupportedFormat(AudioFormat format) { return getConvertType(format)!=0; } --- 126,130 ---- private static final int ULAW=5; ! protected boolean isSupportedFormat(AudioFormat format) { return getConvertType(format)!=0; } |