voxforge.org
VoxForge Dev

Changeset 2374

Show
Ignore:
Timestamp:
12/27/07 17:04:57 (1 year ago)
Author:
kmaclean
Message:

draft fix to ticket #297

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • Trunk/SpeechSubmission/VFSpeechSubmission/java/src/speechrecorder/CapturePlayback.java

    r2367 r2374  
    153153    double seconds; 
    154154    long totalBytesWritten = 0L; 
     155    long totalBytesWritten1 = 0L; 
     156    long totalBytesWritten2 = 0L; 
     157    long totalBytesWritten3 = 0L; 
     158    long totalBytesWritten4 = 0L; 
     159    long totalBytesWritten5 = 0L; 
     160    long totalBytesWritten6 = 0L; 
     161    long totalBytesWritten7 = 0L; 
     162    long totalBytesWritten8 = 0L; 
     163    long totalBytesWritten9 = 0L; 
     164    long totalBytesWritten10 = 0L; 
    155165    File file; 
    156166    Vector lines = new Vector(); 
     
    699709     
    700710    private void setButtonsOff() { 
    701         // debug System.err.println("!!!!!!!setButtonsOff" ); 
    702711        play1.setEnabled(false);  
    703712        capt1.setEnabled(false);  
     
    723732     
    724733    private void saveButtonState() { 
    725         // debug System.err.println("!!!!!!!saveButtonState" ); 
    726734        if (play1.isEnabled()) {play1_state = true;} else {play1_state = false;} 
    727735        if (play2.isEnabled()) {play2_state = true;} else {play2_state = false;}   
     
    747755     
    748756    private void restoreButtonState() { 
    749         // debug System.err.println("!!!!!!restoreButtonState" ); 
    750757        if (play1_state) {play1.setEnabled(true);} else {play1.setEnabled(false);} 
    751758        if (play2_state) {play2.setEnabled(true);} else {play2.setEnabled(false);} 
     
    778785                wavFile = wavFile1;       
    779786                duration = duration1; 
     787                // !!!!!! 
     788                        System.err.println("play1 totalBytesWritten1:" + totalBytesWritten1); 
     789                // !!!!!! 
     790                totalBytesWritten = totalBytesWritten1; 
    780791                playback.start(); 
    781792                fileName = promptID1;   
     
    794805                wavFile = wavFile2;              
    795806                duration = duration2;   
     807                // !!!!!! 
     808                        System.err.println("play2 totalBytesWritten2:" + totalBytesWritten2); 
     809                // !!!!!! 
     810                totalBytesWritten = totalBytesWritten2; 
    796811                playback.start(); 
    797812                fileName = promptID2;  
     
    809824            if (play3.getText().startsWith(playButton)) { 
    810825                wavFile = wavFile3;              
     826                duration = duration3; 
     827                // !!!!!! 
     828                        System.err.println("play3 totalBytesWritten3:" + totalBytesWritten3); 
     829                // !!!!!! 
     830                totalBytesWritten = totalBytesWritten3; 
    811831                playback.start(); 
    812                 duration = duration3; 
    813832                fileName = promptID3;   
    814833                samplingGraph.start(); 
     
    826845                wavFile = wavFile4;              
    827846                duration = duration4; 
     847                // !!!!!! 
     848                        System.err.println("play4 totalBytesWritten4:" + totalBytesWritten4); 
     849                // !!!!!! 
     850                totalBytesWritten = totalBytesWritten4; 
    828851                playback.start(); 
    829852                fileName = promptID4; 
     
    842865                wavFile = wavFile5;              
    843866                duration = duration5; 
     867                // !!!!!! 
     868                        System.err.println("play5 totalBytesWritten5:" + totalBytesWritten5); 
     869                // !!!!!! 
     870                totalBytesWritten = totalBytesWritten5; 
    844871                playback.start(); 
    845872                fileName = promptID5;   
     
    858885                wavFile = wavFile6;              
    859886                duration = duration6; 
     887                totalBytesWritten = totalBytesWritten6; 
    860888                playback.start(); 
    861889                fileName = promptID6;   
     
    874902                wavFile = wavFile7;              
    875903                duration = duration7; 
     904                totalBytesWritten = totalBytesWritten7; 
    876905                playback.start(); 
    877906                fileName = promptID7; 
     
    890919                wavFile = wavFile8;              
    891920                duration = duration8; 
     921                totalBytesWritten = totalBytesWritten8; 
    892922                playback.start(); 
    893923                fileName = promptID8;    
     
    906936                wavFile = wavFile9;                      
    907937                duration = duration9; 
     938                totalBytesWritten = totalBytesWritten9; 
    908939                playback.start(); 
    909940                fileName = promptID9;  
     
    922953                wavFile = wavFile10;                     
    923954                duration = duration10; 
     955                totalBytesWritten = totalBytesWritten10; 
    924956                playback.start(); 
    925957                fileName = promptID10; 
     
    939971            file = null; 
    940972            wavFile = wavFile1;   
    941             duration1 = 0; 
    942             capture.start(uploadWavFile1);   
     973//            duration1 = 0; 
     974            capture.start(uploadWavFile1);   
    943975            duration1 = duration; 
    944976            fileName = promptID1; 
     
    953985            lines.removeAllElements();   
    954986            capture.stop(); 
     987            totalBytesWritten1 = totalBytesWritten; 
     988            // !!!!!! 
     989                System.err.println("capt1 totalBytesWritten1:" + totalBytesWritten1); 
     990            // !!!!!! 
    955991            samplingGraph.stop(); 
    956992            restoreButtonState();  
     
    9661002              file = null; 
    9671003              wavFile = wavFile2;  
    968               duration2 = 0; 
    969               capture.start(uploadWavFile2);  
     1004 //             duration2 = 0; 
     1005              capture.start(uploadWavFile2);  
    9701006              duration2 = duration; 
    9711007              fileName = promptID2; 
     
    9801016              lines.removeAllElements();   
    9811017              capture.stop(); 
     1018              totalBytesWritten2 = totalBytesWritten; 
     1019              // !!!!!! 
     1020                  System.err.println("capt2 totalBytesWritten2:" + totalBytesWritten2); 
     1021              // !!!!!! 
    9821022              samplingGraph.stop(); 
    9831023              restoreButtonState();  
     
    9931033              file = null; 
    9941034              wavFile = wavFile3;  
    995               duration3 = 0; 
     1035 //             duration3 = 0; 
    9961036              capture.start(uploadWavFile3);    
    9971037              duration3 = duration; 
     
    10071047              lines.removeAllElements();   
    10081048              capture.stop(); 
     1049              totalBytesWritten3 = totalBytesWritten; 
     1050              // !!!!!! 
     1051                  System.err.println("capt3 totalBytesWritten3:" + totalBytesWritten3); 
     1052              // !!!!!! 
    10091053              samplingGraph.stop(); 
    10101054              restoreButtonState();  
     
    10191063          if (capt4.getText().startsWith(recordButton)) { 
    10201064              file = null; 
    1021               wavFile = wavFile4;               
     1065              wavFile = wavFile4;      
     1066 //             duration4 = 0; 
    10221067              capture.start(uploadWavFile4);  
    1023               duration4 = 0; 
    10241068              duration4 = duration; 
    10251069              fileName = promptID4; 
     
    10341078              lines.removeAllElements();   
    10351079              capture.stop(); 
     1080              totalBytesWritten4 = totalBytesWritten; 
     1081              // !!!!!! 
     1082                  System.err.println("capt4 totalBytesWritten4:" + totalBytesWritten4); 
     1083              // !!!!!! 
    10361084              samplingGraph.stop(); 
    10371085              restoreButtonState();  
     
    10461094          if (capt5.getText().startsWith(recordButton)) { 
    10471095              file = null; 
    1048               wavFile = wavFile5;                
     1096              wavFile = wavFile5;     
     1097  //            duration5 = 0; 
    10491098              capture.start(uploadWavFile5);   
    1050               duration5 = 0; 
    10511099              duration5 = duration; 
    10521100              fileName = promptID5; 
     
    10611109              lines.removeAllElements();   
    10621110              capture.stop(); 
     1111              totalBytesWritten5 = totalBytesWritten; 
     1112              // !!!!!! 
     1113                  System.err.println("capt5 totalBytesWritten5:" + totalBytesWritten5); 
     1114              // !!!!!! 
    10631115              samplingGraph.stop(); 
    10641116              restoreButtonState();  
     
    10741126              file = null; 
    10751127              wavFile = wavFile6;   
    1076               duration6 = 0; 
     1128 //             duration6 = 0; 
    10771129              capture.start(uploadWavFile6);   
     1130              totalBytesWritten6 = totalBytesWritten; 
    10781131              duration6 = duration; 
    10791132              fileName = promptID6; 
     
    11011154                file = null; 
    11021155                wavFile = wavFile7;      
    1103                 duration7 = 0; 
     1156 //               duration7 = 0; 
    11041157                capture.start(uploadWavFile7);   
     1158                totalBytesWritten7 = totalBytesWritten; 
    11051159                duration7 = duration; 
    11061160                fileName = promptID7; 
     
    11281182                file = null; 
    11291183                wavFile = wavFile8;   
    1130                 duration8 = 0; 
     1184  //              duration8 = 0; 
    11311185                capture.start(uploadWavFile8);    
     1186                totalBytesWritten8 = totalBytesWritten; 
    11321187                duration8 = duration; 
    11331188                fileName = promptID8; 
     
    11551210                file = null; 
    11561211                wavFile = wavFile9;    
    1157                 duration9 = 0; 
     1212  //              duration9 = 0; 
    11581213                capture.start(uploadWavFile9);   
     1214                totalBytesWritten9 = totalBytesWritten; 
    11591215                duration9 = duration; 
    11601216                fileName = promptID9; 
     
    11821238                file = null; 
    11831239                wavFile = wavFile10;     
    1184                 duration10 = 0; 
    1185                 capture.start(uploadWavFile10);    
     1240  //              duration10 = 0; 
     1241                capture.start(uploadWavFile10);  
     1242                totalBytesWritten10 = totalBytesWritten; 
    11861243                duration10 = duration; 
    11871244                fileName = promptID10; 
     
    13351392       } 
    13361393 
    1337        // reset to the beginnning of the captured data 
     1394       // reset to the beginning of the captured data 
    13381395       try { 
    13391396           audioInputStream.reset(); 
     
    13691426 
    13701427        public void start() { 
     1428                // !!!!!! 
     1429                System.err.println("=== Play ========================================================="); 
     1430                // !!!!!! 
     1431  
    13711432            errStr = null; 
    13721433            thread = new Thread(this); 
     
    14411502            } 
    14421503*/ 
    1443             System.err.println("calling getAudioInputStream from Capture"); 
     1504            // debug System.err.println("calling getAudioInputStream from Playback"); 
    14441505                        getAudioInputStream(); 
    14451506 
     
    14871548                    } 
    14881549                                        outbaos.write(data, 0, numBytesRead); 
     1550                                        // !!!!!! 
     1551                                /// System.err.println("numBytesRead" + numBytesRead); 
     1552                                        // !!!!!! 
    14891553                } catch (Exception e) { 
    14901554                    shutDown("Error during playback: " + e); 
     
    14931557            }        
    14941558            byte audioBytes[] = outbaos.toByteArray(); 
     1559            // !!!!!! 
     1560                System.err.println("outbaos size:" + outbaos.size());             
     1561                outbaos.reset(); 
     1562                outbaos = null; 
     1563                // !!!!!!  
    14951564            samplingGraph.createWaveForm(audioBytes);  
    14961565            samplingGraph.repaint(); 
     
    15531622        public void start(File uploadWavFile) { 
    15541623                this.uploadWavFile = uploadWavFile;  
     1624                // !!!!!! 
     1625                System.err.println("== Capture ========================================================="); 
     1626                // !!!!!! 
    15551627                System.err.println("Capture uploadWavFile is:" + uploadWavFile); 
    15561628 
     
    17001772                        } 
    17011773                } 
    1702          
    1703                 // debug System.err.println("About to grab audio input stream from cache file"); 
     1774// !!!!!! 
     1775                System.err.println("getAudioInputStream - totalBytesWritten:" + totalBytesWritten); 
     1776// !!!!!! 
    17041777                try { 
    17051778                        //              audioInputStream = AudioSystem.getAudioInputStream(wavFile); 
     1779 
    17061780                        audioInputStream = new AudioInputStream(new BufferedInputStream( 
    17071781                                        new FileInputStream(wavFile)), format, totalBytesWritten 
     
    17181792     
    17191793    /**  
    1720      * Performs the Speex compression AND uploads the file 
     1794     * uploads the file 
    17211795     */ 
    17221796    class ConvertAndUpload implements Runnable {