Changeset 1557 for trunk/src/org/apollo/widgets/SampledTrack.java
- Timestamp:
- 05/10/21 11:26:08 (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/apollo/widgets/SampledTrack.java
r1556 r1557 2102 2102 AudioFormat sourceFormat = sourceStream.getFormat(); 2103 2103 2104 // is already mono?2105 /*if(sourceFormat.getChannels() == 1) {2106 return sourceStream;2107 }2108 */2109 2104 if (sourceFormat.getChannels() > 1) { 2110 2105 … … 2126 2121 } 2127 2122 2128 // better to express in terms of targetFormat !!!2123 // **** better to express in terms of targetFormat !!! 2129 2124 boolean is_signed = (sourceFormat.getEncoding() == Encoding.PCM_SIGNED); 2130 2125 2131 2126 TarsosDSPAudioFormat ts_audioFormat = new TarsosDSPAudioFormat( 2132 /* sample rate */sourceFormat.getSampleRate(),2133 /* HERE sample size in bits */sourceFormat.getSampleSizeInBits(),2134 /* number of channels */1,2135 /* signed/unsigned data */is_signed,2136 /* big-endian byte order */sourceFormat.isBigEndian()2127 sourceFormat.getSampleRate(), 2128 sourceFormat.getSampleSizeInBits(), 2129 1, 2130 is_signed, 2131 sourceFormat.isBigEndian() 2137 2132 ); 2138 2133 … … 2169 2164 // Need to make 44.1 kHz mono version (if does not already exist) 2170 2165 2171 2172 2166 String orig_local_filename_root = orig_local_filename.substring(0,orig_local_filename.lastIndexOf('.')); 2173 2167 … … 2187 2181 UniversalAudioInputStream mono_audio_input_stream = convertToMono(orig_audio_input_stream); 2188 2182 TarsosDSPAudioFormat ts_audioFormat = mono_audio_input_stream.getFormat(); 2189 2190 //AudioFormat mono_format = mono_audio_input_stream.getFormat(); 2191 2192 2193 2194 2195 //double orig_sample_rate = orig_format.getSampleRate(); 2196 //double mono_sample_rate = mono_format.getSampleRate(); 2197 2198 2199 //https://stackoverflow.com/questions/31365172/tarsosdsp-pitch-detection-from-wav-file-and-the-result-frequency-is-always-les 2200 /* 2201 InputStream is = new FileInputStream(orig_source_file); 2202 2203 TarsosDSPAudioFormat ts_audioFormat = new TarsosDSPAudioFormat( 2204 / * sample rate * / 44100, 2205 / * HERE sample size in bits * / 16, // used to be 32 2206 / * number of channels * / 1, 2207 / * signed/unsigned data * / true, 2208 / * big-endian byte order * / false 2209 ); 2210 UniversalAudioInputStream uis = new UniversalAudioInputStream(is, ts_audioFormat); 2211 2212 */ 2213 2214 //AudioDispatcher dispatcher = new AudioDispatcher(uis, 2048, 0); 2215 2216 2183 2217 2184 2218 2185 // Consider allowing finer grained control of WSOLA params through @annotations: … … 2226 2193 WaveformWriter stretched_target_writer = new WaveformWriter(ts_audioFormat,stretched_target); 2227 2194 2228 //AudioDispatcher dispatcher = AudioDispatcherFactory.fromFile(orig_source_file,wsola.getInputBufferSize(),wsola.getOverlap());2229 2195 AudioDispatcher dispatcher = new AudioDispatcher(mono_audio_input_stream,wsola.getInputBufferSize(),wsola.getOverlap()); 2230 2196 wsola.setDispatcher(dispatcher); … … 2234 2200 dispatcher.run(); 2235 2201 System.out.println("... done"); 2236 2237 //AudioFormat stretched_target_format = AudioSystem.getAudioFileFormat(stretched_target_file).getFormat();2238 2202 2239 2203 } … … 2308 2272 // Conditions are right, to play! 2309 2273 2310 /*2311 2274 Frame current = DisplayController.getCurrentFrame(); 2312 2275 // Or perhaps (??) we should be getting the current frame via: 2313 2276 //Frame current = getSource().getParentOrCurrentFrame(); 2314 2277 2315 //Text time_stretch_annotation = current.getAnnotation("TimeStretchFactor");2316 2278 String time_stretch_annotation_valuestr = current.getAnnotationValue("TimeStretchFactor"); 2317 2279 2318 2280 if (time_stretch_annotation_valuestr != null) { 2319 //String time_stretch_str = time_stretch_annotation.getText();2320 //time_stretch_str = time_stretch_str.replaceFirst("^\\s*@time-stretch-factor(:?)\\s*","");2321 //System.out.println("**** time stretch str = " + time_stretch_annotation_valuestr);2322 2281 2323 2282 double time_stretch = Double.parseDouble(time_stretch_annotation_valuestr); … … 2330 2289 } 2331 2290 } 2332 */2333 2334 2291 2335 2292 SoundDesk.getInstance().playSampledTrackModel(
Note:
See TracChangeset
for help on using the changeset viewer.