Changeset 1007 for trunk/src/org/apollo/audio/SampledAudioManager.java
- Timestamp:
- 03/08/16 23:22:09 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/apollo/audio/SampledAudioManager.java
r355 r1007 14 14 import org.apollo.mvc.SubjectChangedEvent; 15 15 import org.apollo.util.ApolloSystemLog; 16 16 17 17 18 /** … … 27 28 28 29 /** All internal formats have the same sample rate. */ 29 public static final float PLAYBACK_SAMPLE_RATE = 44100.0f; // Audacitys default 30 31 //public static final float PLAYBACK_SAMPLE_RATE = 22050.0f; // Meldexes internal rate .. todo: fix conversions to use better rate 32 33 // Used for describing the ideal default format for recorded audio and converting un-supported 30 // The following is based on Audacity's defaults for playback 31 public static final float PLAYBACK_SAMPLE_RATE = 44100.0f; 32 public static final int PLAYBACK_BITS_PER_SAMPLE = 16; 33 public static final int PLAYBACK_NUM_CHANNELS = 2; // stereo 34 35 //public static final float PLAYBACK_SAMPLE_RATE = 22050.0f; // Meldexe's internal rate .. todo: fix conversions to use better rate 36 37 // Used for describing the ideal default format for recorded audio and converting unsupported 34 38 // imported audio to... The actual formats may differ depending on the data lines used 35 39 36 // note: Must be PCM, Mono, 16 bit.40 // note: Must be PCM, with values as defined for PLAYBACK_... above 37 41 private static final AudioFormat DESIRED_FORMAT = new AudioFormat( // Linear PCM Encoding 38 PLAYBACK_SAMPLE_RATE, // Always conform to PLAYBACK_SAMPLE_RATE 39 16, // bits per sample. Must be 16. Audacitys default40 1, // Always use mono. Audacitys default42 PLAYBACK_SAMPLE_RATE, // Always conform to PLAYBACK_SAMPLE_RATE etc 43 PLAYBACK_BITS_PER_SAMPLE, 44 PLAYBACK_NUM_CHANNELS, 41 45 false, // ALWAYS USED SIGNED FOR BEST PERFORMACE - JAVA DOES NOT HAVE UNSIGNED TYPES 42 46 true // Byte order … … 231 235 // Not cadidate if not in appollos format. 232 236 if (!candiate.getEncoding().toString().startsWith("PCM") 233 || candiate.getChannels() != 1234 || candiate.getSampleSizeInBits() != 16237 || candiate.getChannels() != PLAYBACK_NUM_CHANNELS 238 || candiate.getSampleSizeInBits() != PLAYBACK_BITS_PER_SAMPLE 235 239 || (candiate.getSampleRate() != AudioSystem.NOT_SPECIFIED && 236 240 candiate.getSampleRate() != PLAYBACK_SAMPLE_RATE)) … … 285 289 /** 286 290 * Determines if an audio format requires conversion in order to be used 287 * in Apollos. 288 * 289 * Audio formats must be in PCM, mono, 16-bit sample-size, 291 * in Apollo's. 292 * 293 * Audio formats must be in PCM, SampledAudioManager#PLAYBACK_NUM_CHANNELS, 294 * SampledAudioManager#PLAYBACK_BITS_PER_SAMPLE sample-size, 290 295 * SampledAudioManager#PLAYBACK_SAMPLE_RATE sample-rate and be supported 291 296 * by the output mixer. … … 304 309 if (format == null) throw new NullPointerException("format"); 305 310 306 if(!format.getEncoding().toString().startsWith("PCM") || format.getChannels() != 1307 || format.getSampleSizeInBits() != 16311 if(!format.getEncoding().toString().startsWith("PCM") || format.getChannels() != PLAYBACK_NUM_CHANNELS 312 || format.getSampleSizeInBits() != PLAYBACK_BITS_PER_SAMPLE 308 313 || (format.getSampleRate() != AudioSystem.NOT_SPECIFIED && 309 314 format.getSampleRate() != PLAYBACK_SAMPLE_RATE)) { … … 313 318 // Check that the format is supported by the output mixer 314 319 for (AudioFormat supported : supportedPlaybackFormats) { 315 if (supported.getChannels() != 1) continue;320 if (supported.getChannels() != PLAYBACK_NUM_CHANNELS) continue; 316 321 if ( 317 322 format.getEncoding() == supported.getEncoding()
Note:
See TracChangeset
for help on using the changeset viewer.