Changeset 1557


Ignore:
Timestamp:
05/10/21 11:26:08 (3 years ago)
Author:
davidb
Message:

Code tidy up

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/apollo/widgets/SampledTrack.java

    r1556 r1557  
    21022102                    AudioFormat sourceFormat = sourceStream.getFormat();
    21032103
    2104                     // is already mono?
    2105                     /*if(sourceFormat.getChannels() == 1) {
    2106                         return sourceStream;
    2107                     }
    2108 */
    21092104                    if (sourceFormat.getChannels() > 1) {
    21102105                   
     
    21262121                    }
    21272122                   
    2128                     // better to express in terms of targetFormat !!!
     2123                    // **** better to express in terms of targetFormat !!!
    21292124                    boolean is_signed = (sourceFormat.getEncoding() == Encoding.PCM_SIGNED);
    21302125                   
    21312126                        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()
    21372132                                        );
    21382133                       
     
    21692164                                        // Need to make 44.1 kHz mono version (if does not already exist)
    21702165                                       
    2171                                        
    21722166                                        String orig_local_filename_root = orig_local_filename.substring(0,orig_local_filename.lastIndexOf('.'));
    21732167                               
     
    21872181                                                UniversalAudioInputStream mono_audio_input_stream = convertToMono(orig_audio_input_stream);
    21882182                                                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                                                                                               
    22172184                                               
    22182185                                                // Consider allowing finer grained control of WSOLA params through @annotations:
     
    22262193                                                WaveformWriter stretched_target_writer = new WaveformWriter(ts_audioFormat,stretched_target);
    22272194
    2228                                                 //AudioDispatcher dispatcher = AudioDispatcherFactory.fromFile(orig_source_file,wsola.getInputBufferSize(),wsola.getOverlap());
    22292195                                                AudioDispatcher dispatcher = new AudioDispatcher(mono_audio_input_stream,wsola.getInputBufferSize(),wsola.getOverlap());
    22302196                                                wsola.setDispatcher(dispatcher);
     
    22342200                                                dispatcher.run();
    22352201                                                System.out.println("... done");
    2236 
    2237                                                 //AudioFormat stretched_target_format = AudioSystem.getAudioFileFormat(stretched_target_file).getFormat();     
    22382202
    22392203                                        }
     
    23082272                                        // Conditions are right, to play!
    23092273                                       
    2310                                         /*
    23112274                                        Frame current = DisplayController.getCurrentFrame();
    23122275                                        // Or perhaps (??) we should be getting the current frame via:
    23132276                                        //Frame current = getSource().getParentOrCurrentFrame();
    23142277                                       
    2315                                         //Text time_stretch_annotation = current.getAnnotation("TimeStretchFactor");
    23162278                                        String time_stretch_annotation_valuestr = current.getAnnotationValue("TimeStretchFactor");
    23172279                                       
    23182280                                        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);
    23222281                                               
    23232282                                                double time_stretch = Double.parseDouble(time_stretch_annotation_valuestr);
     
    23302289                                                }
    23312290                                        }
    2332                                         */
    2333                                
    23342291                                       
    23352292                                        SoundDesk.getInstance().playSampledTrackModel(
Note: See TracChangeset for help on using the changeset viewer.