author | llornkcor <llornkcor> | 2003-08-10 23:03:39 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-08-10 23:03:39 (UTC) |
commit | 892aac84512b257c72362702a98462289589faec (patch) (unidiff) | |
tree | d514fbd450129f2a1b2a897ef06c93e27cde4b30 | |
parent | 44bb1f23dcd0bea4775ba4b48fb370ad651290cc (diff) | |
download | opie-892aac84512b257c72362702a98462289589faec.zip opie-892aac84512b257c72362702a98462289589faec.tar.gz opie-892aac84512b257c72362702a98462289589faec.tar.bz2 |
forgot what I changed, but I changed something I need to commit
-rw-r--r-- | noncore/multimedia/opierec/qtrec.cpp | 200 | ||||
-rw-r--r-- | noncore/multimedia/opierec/qtrec.h | 2 |
2 files changed, 58 insertions, 144 deletions
diff --git a/noncore/multimedia/opierec/qtrec.cpp b/noncore/multimedia/opierec/qtrec.cpp index 147f63d..2bf795f 100644 --- a/noncore/multimedia/opierec/qtrec.cpp +++ b/noncore/multimedia/opierec/qtrec.cpp | |||
@@ -108,9 +108,4 @@ void quickRec() { | |||
108 | //void QtRec::quickRec() { | 108 | //void QtRec::quickRec() { |
109 | 109 | ||
110 | qDebug("%d", | ||
111 | filePara.numberSamples/filePara.sampleRate * filePara.channels); | ||
112 | qDebug("samples %d, rate %d, channels %d", | ||
113 | filePara.numberSamples, filePara.sampleRate, filePara.channels); | ||
114 | |||
115 | int total = 0; // Total number of bytes read in so far. | 110 | int total = 0; // Total number of bytes read in so far. |
116 | int bytesWritten, number; | 111 | int bytesWritten, number; |
@@ -128,16 +123,10 @@ void quickRec() { | |||
128 | recording = true; | 123 | recording = true; |
129 | //rate=filePara.sampleRate; | 124 | //rate=filePara.sampleRate; |
130 | int bits = filePara.resolution; | 125 | // int bits = filePara.resolution; |
131 | qDebug("bits %d", bits); | ||
132 | // if( filePara.format==WAVE_FORMAT_DVI_ADPCM) | ||
133 | // else | ||
134 | audio_buf_info inInfo; | 126 | audio_buf_info inInfo; |
135 | ioctl( filePara.fd, SNDCTL_DSP_GETISPACE, &inInfo); | 127 | ioctl( filePara.fd, SNDCTL_DSP_GETISPACE, &inInfo); |
136 | qDebug("ispace is frags %d, total %d", inInfo.fragments, inInfo.fragstotal); | 128 | // qDebug("ispace is frags %d, total %d", inInfo.fragments, inInfo.fragstotal); |
137 | 129 | ||
138 | if( filePara.resolution == 16 ) { //AFMT_S16_LE) | 130 | if( filePara.resolution == 16 ) { //AFMT_S16_LE) |
139 | qDebug("AFMT_S16_LE size %d", filePara.SecondsToRecord); | ||
140 | qDebug("samples to record %d", filePara.samplesToRecord); | ||
141 | qDebug("%d", filePara.sd); | ||
142 | level=7; | 131 | level=7; |
143 | threshold=0; | 132 | threshold=0; |
@@ -146,6 +135,5 @@ void quickRec() { | |||
146 | 135 | ||
147 | if( filePara.format==WAVE_FORMAT_DVI_ADPCM) { | 136 | if( filePara.format==WAVE_FORMAT_DVI_ADPCM) { |
148 | qDebug("start recording WAVE_FORMAT_DVI_ADPCM"); | 137 | // qDebug("start recording WAVE_FORMAT_DVI_ADPCM"); |
149 | // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_DVI_ADPCM >>>>>>>>>>>>>>>>>>>>>> | ||
150 | char abuf[BUFSIZE/2]; | 138 | char abuf[BUFSIZE/2]; |
151 | short sbuf[BUFSIZE]; | 139 | short sbuf[BUFSIZE]; |
@@ -157,19 +145,14 @@ void quickRec() { | |||
157 | for(;;) { | 145 | for(;;) { |
158 | if (stopped) { | 146 | if (stopped) { |
159 | qDebug("quickRec:: stopped"); | ||
160 | break; // stop if playing was set to false | 147 | break; // stop if playing was set to false |
161 | // return; | ||
162 | } | 148 | } |
163 | 149 | ||
164 | number=::read( filePara.sd, sbuf, BUFSIZE); | 150 | number=::read( filePara.sd, sbuf, BUFSIZE); |
165 | |||
166 | if(number <= 0) { | 151 | if(number <= 0) { |
167 | perror("recording error "); | 152 | perror("recording error "); |
168 | qDebug( "%s %d", filePara.fileName, number); | 153 | // qDebug( "%s %d", filePara.fileName, number); |
169 | // errorStop(); | 154 | // errorStop(); |
170 | recording=stopped=false; | 155 | recording=stopped=false; |
171 | // QMessageBox::message("Note", | 156 | // QMessageBox::message("Note", "Error recording to file\n%s",filePara.fileName); |
172 | // "Error recording to file\n%s", | ||
173 | // filePara.fileName); | ||
174 | return; | 157 | return; |
175 | } | 158 | } |
@@ -177,7 +160,5 @@ void quickRec() { | |||
177 | // adpcm_coder( sbuf2, abuf, number/2, &encoder_state); | 160 | // adpcm_coder( sbuf2, abuf, number/2, &encoder_state); |
178 | adpcm_coder( sbuf, abuf, number/2, &encoder_state); | 161 | adpcm_coder( sbuf, abuf, number/2, &encoder_state); |
179 | |||
180 | bytesWritten = ::write( filePara.fd , abuf, number/4); | 162 | bytesWritten = ::write( filePara.fd , abuf, number/4); |
181 | |||
182 | long peak; | 163 | long peak; |
183 | for (int i = 0; i < number; i++) | 164 | for (int i = 0; i < number; i++) |
@@ -187,6 +168,4 @@ void quickRec() { | |||
187 | fflush(stdout); | 168 | fflush(stdout); |
188 | } | 169 | } |
189 | |||
190 | |||
191 | //------------->>>> out to file | 170 | //------------->>>> out to file |
192 | // if(filePara.channels==1) | 171 | // if(filePara.channels==1) |
@@ -201,15 +180,5 @@ void quickRec() { | |||
201 | 180 | ||
202 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2; | 181 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate * (float)2; |
203 | |||
204 | // printf("Writing number %d, bytes %d,total %d, sample rate %d, secs %.2f \n", | ||
205 | // number, | ||
206 | // bytesWritten , | ||
207 | // total, | ||
208 | // filePara.sampleRate, | ||
209 | // filePara.numberOfRecordedSeconds); | ||
210 | // fflush(stdout); | ||
211 | ioctl( filePara.sd, SNDCTL_DSP_GETIPTR, &info); | 182 | ioctl( filePara.sd, SNDCTL_DSP_GETIPTR, &info); |
212 | // qDebug("%d, %d", info.bytes, (info.bytes / filePara.sampleRate) / 2); | ||
213 | |||
214 | timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds); | 183 | timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds); |
215 | timeLabel->setText( timeString + " seconds"); | 184 | timeLabel->setText( timeString + " seconds"); |
@@ -220,6 +189,5 @@ void quickRec() { | |||
220 | } | 189 | } |
221 | } else { | 190 | } else { |
222 | // <<<<<<<<<<<<<<<<<<<<<<<<<<< WAVE_FORMAT_PCM >>>>>>>>>>>>>>>>>>>>>> | 191 | // qDebug("start recording WAVE_FORMAT_PCM"); |
223 | qDebug("start recording WAVE_FORMAT_PCM"); | ||
224 | short inbuffer[BUFSIZE], outbuffer[BUFSIZE]; | 192 | short inbuffer[BUFSIZE], outbuffer[BUFSIZE]; |
225 | memset( inbuffer,0,BUFSIZE); | 193 | memset( inbuffer,0,BUFSIZE); |
@@ -227,21 +195,15 @@ void quickRec() { | |||
227 | for(;;) { | 195 | for(;;) { |
228 | if (stopped) { | 196 | if (stopped) { |
229 | qDebug("quickRec:: stopped"); | ||
230 | break; // stop if playing was set to false | 197 | break; // stop if playing was set to false |
231 | return; | ||
232 | } | 198 | } |
233 | 199 | ||
234 | number=::read( filePara.sd, inbuffer, BUFSIZE); | 200 | number=::read( filePara.sd, inbuffer, BUFSIZE); |
235 | |||
236 | if(number <= 0) { | 201 | if(number <= 0) { |
237 | perror("recording error "); | 202 | perror("recording error "); |
238 | qDebug( filePara.fileName); | ||
239 | recording=stopped=false; | 203 | recording=stopped=false; |
240 | // errorStop(); | 204 | // errorStop(); |
241 | // QMessageBox::message("Note","error recording to file\n%s",filePara.fileName); | ||
242 | return;// false; | 205 | return;// false; |
243 | } | 206 | } |
244 | /* for (int i=0;i< number;i++) { //2*i is left channel | 207 | /* for (int i=0;i< number;i++) { //2*i is left channel |
245 | |||
246 | outbuffer[i]=inbuffer[i]>>1; // no clippy, please | 208 | outbuffer[i]=inbuffer[i]>>1; // no clippy, please |
247 | }*/ | 209 | }*/ |
@@ -265,6 +227,4 @@ outbuffer[i]=inbuffer[i]>>1; // no clippy, please | |||
265 | fflush(stdout); | 227 | fflush(stdout); |
266 | } | 228 | } |
267 | |||
268 | |||
269 | filePara.numberSamples = total; | 229 | filePara.numberSamples = total; |
270 | if(filePara.SecondsToRecord !=0) | 230 | if(filePara.SecondsToRecord !=0) |
@@ -277,8 +237,6 @@ outbuffer[i]=inbuffer[i]>>1; // no clippy, please | |||
277 | 237 | ||
278 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2; | 238 | filePara.numberOfRecordedSeconds = (float)total / (float)filePara.sampleRate / (float)2; |
279 | |||
280 | timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds); | 239 | timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds); |
281 | timeLabel->setText( timeString + " seconds"); | 240 | timeLabel->setText( timeString + " seconds"); |
282 | |||
283 | qApp->processEvents(); | 241 | qApp->processEvents(); |
284 | if( total >= filePara.samplesToRecord) | 242 | if( total >= filePara.samplesToRecord) |
@@ -294,5 +252,5 @@ outbuffer[i]=inbuffer[i]>>1; // no clippy, please | |||
294 | for(;;) { | 252 | for(;;) { |
295 | if (stopped) { | 253 | if (stopped) { |
296 | qDebug("quickRec:: stopped"); | 254 | // qDebug("quickRec:: stopped"); |
297 | break; // stop if playing was set to false | 255 | break; // stop if playing was set to false |
298 | } | 256 | } |
@@ -349,9 +307,5 @@ void playIt() { | |||
349 | } | 307 | } |
350 | 308 | ||
351 | |||
352 | |||
353 | /////////////////<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>> | 309 | /////////////////<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>> |
354 | /////////////////<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>> | ||
355 | |||
356 | QtRec::QtRec( QWidget* parent, const char* name, WFlags fl ) | 310 | QtRec::QtRec( QWidget* parent, const char* name, WFlags fl ) |
357 | : QWidget( parent, name, fl ) { | 311 | : QWidget( parent, name, fl ) { |
@@ -360,6 +314,4 @@ QtRec::QtRec( QWidget* parent, const char* name, WFlags fl ) | |||
360 | // QPEApplication::grabKeyboard(); | 314 | // QPEApplication::grabKeyboard(); |
361 | 315 | ||
362 | // signal(SIGPIPE, SIG_IGN); | ||
363 | |||
364 | if ( !name ) | 316 | if ( !name ) |
365 | setName( "OpieRec" ); | 317 | setName( "OpieRec" ); |
@@ -412,5 +364,4 @@ void QtRec::cleanUp() { | |||
412 | if(wavFile) delete wavFile; | 364 | if(wavFile) delete wavFile; |
413 | // if(soundDevice) delete soundDevice; | 365 | // if(soundDevice) delete soundDevice; |
414 | |||
415 | // QPEApplication::grabKeyboard(); | 366 | // QPEApplication::grabKeyboard(); |
416 | // QPEApplication::ungrabKeyboard(); | 367 | // QPEApplication::ungrabKeyboard(); |
@@ -755,7 +706,8 @@ void QtRec::initIconView() { | |||
755 | QString fileS, mediaLocation, fileDate, filePath; | 706 | QString fileS, mediaLocation, fileDate, filePath; |
756 | 707 | ||
757 | // temp.sprintf("%d",i); | 708 | temp.sprintf("%d",i); |
758 | temp=cfg.readEntry(temp,""); //reads currentFile | 709 | temp=cfg.readEntry(temp,""); //reads currentFile |
759 | filePath = cfg.readEntry(temp,""); //currentFileName | 710 | filePath = cfg.readEntry(temp,""); //currentFileName |
711 | // qDebug(filePath); | ||
760 | 712 | ||
761 | QFileInfo info(filePath); | 713 | QFileInfo info(filePath); |
@@ -860,5 +812,5 @@ void QtRec::initConfig() { | |||
860 | 812 | ||
861 | void QtRec::stop() { | 813 | void QtRec::stop() { |
862 | qDebug("<<<<<<<<<stop()"); | 814 | // qDebug("<<<<<<<<<stop()"); |
863 | setRecordButton(false); | 815 | setRecordButton(false); |
864 | monitoring=false; | 816 | monitoring=false; |
@@ -888,5 +840,4 @@ void QtRec::doPlayBtn() { | |||
888 | void QtRec::start() { //play | 840 | void QtRec::start() { //play |
889 | if(stopped) { | 841 | if(stopped) { |
890 | qDebug("start::"); | ||
891 | QPixmap image3( ( const char** ) image3_data ); | 842 | QPixmap image3( ( const char** ) image3_data ); |
892 | Stop_PushButton->setPixmap( image3 ); | 843 | Stop_PushButton->setPixmap( image3 ); |
@@ -903,11 +854,8 @@ void QtRec::start() { //play | |||
903 | 854 | ||
904 | bool QtRec::rec() { //record | 855 | bool QtRec::rec() { //record |
905 | qDebug("rec()"); | ||
906 | if(!stopped) { | 856 | if(!stopped) { |
907 | qDebug("rec:: !stopped"); | ||
908 | monitoring=true; | 857 | monitoring=true; |
909 | return false; | 858 | return false; |
910 | } else { | 859 | } else { |
911 | qDebug("go ahead and record"); | ||
912 | secCount=1; | 860 | secCount=1; |
913 | playLabel2->setText(tr("Stop")); | 861 | playLabel2->setText(tr("Stop")); |
@@ -918,18 +866,11 @@ bool QtRec::rec() { //record | |||
918 | if( setupAudio( true)) | 866 | if( setupAudio( true)) |
919 | if(setUpFile()) { | 867 | if(setUpFile()) { |
920 | qDebug("Ok to start recording"); | ||
921 | int fileSize=0; | 868 | int fileSize=0; |
922 | Config cfg("OpieRec"); | 869 | Config cfg("OpieRec"); |
923 | cfg.setGroup("Settings"); | 870 | cfg.setGroup("Settings"); |
924 | qDebug( "<<<<<<<Device bits %d, device rate %d, device channels %d", | ||
925 | soundDevice->getDeviceBits(), | ||
926 | soundDevice->getDeviceRate(), | ||
927 | soundDevice->getDeviceChannels()); | ||
928 | |||
929 | //filePara.sampleRate = cfg.readNumEntry("samplerate", 22050); | 871 | //filePara.sampleRate = cfg.readNumEntry("samplerate", 22050); |
930 | qDebug("sample rate is %d", filePara.sampleRate); | 872 | // qDebug("sample rate is %d", filePara.sampleRate); |
931 | filePara.SecondsToRecord = getCurrentSizeLimit(); | 873 | filePara.SecondsToRecord = getCurrentSizeLimit(); |
932 | 874 | ||
933 | qDebug("size limit %d sec", filePara.SecondsToRecord); | ||
934 | int diskSize = checkDiskSpace( (const QString &) wavFile->trackName()); | 875 | int diskSize = checkDiskSpace( (const QString &) wavFile->trackName()); |
935 | 876 | ||
@@ -937,9 +878,7 @@ bool QtRec::rec() { //record | |||
937 | fileSize = diskSize; | 878 | fileSize = diskSize; |
938 | } else if( filePara.format==WAVE_FORMAT_PCM) { | 879 | } else if( filePara.format==WAVE_FORMAT_PCM) { |
939 | qDebug("WAVE_FORMAT_PCM"); | ||
940 | fileSize = (filePara.SecondsToRecord ) * filePara.channels | 880 | fileSize = (filePara.SecondsToRecord ) * filePara.channels |
941 | * filePara.sampleRate *(filePara.resolution/8)+1000; | 881 | * filePara.sampleRate *(filePara.resolution/8)+1000; |
942 | } else { | 882 | } else { |
943 | qDebug("WAVE_FORMAT_DVI_ADPCM"); | ||
944 | fileSize = ((filePara.SecondsToRecord) * filePara.channels | 883 | fileSize = ((filePara.SecondsToRecord) * filePara.channels |
945 | * filePara.sampleRate *(filePara.resolution/8) )/4+250; | 884 | * filePara.sampleRate *(filePara.resolution/8) )/4+250; |
@@ -947,14 +886,8 @@ bool QtRec::rec() { //record | |||
947 | 886 | ||
948 | filePara.samplesToRecord = fileSize; | 887 | filePara.samplesToRecord = fileSize; |
949 | qDebug("filesize should be %d, bits %d, rate %d", | ||
950 | filePara.samplesToRecord, filePara.resolution, filePara.sampleRate); | ||
951 | if(paused) { | 888 | if(paused) { |
952 | paused = false; | 889 | paused = false; |
953 | } | 890 | } |
954 | // else { | ||
955 | qDebug("Setting timeslider %d", filePara.samplesToRecord); | ||
956 | // if(fileSize != 0) | ||
957 | timeSlider->setRange(0, filePara.samplesToRecord); | 891 | timeSlider->setRange(0, filePara.samplesToRecord); |
958 | // } | ||
959 | 892 | ||
960 | if( diskSize < fileSize/1024) { | 893 | if( diskSize < fileSize/1024) { |
@@ -972,9 +905,7 @@ bool QtRec::rec() { //record | |||
972 | #endif | 905 | #endif |
973 | filePara.fileName=currentFile.latin1(); | 906 | filePara.fileName=currentFile.latin1(); |
974 | qDebug("Start recording thread"); | ||
975 | 907 | ||
976 | pthread_t thread1; | 908 | pthread_t thread1; |
977 | pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/); | 909 | pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/); |
978 | // quickRec(); | ||
979 | toBeginningButton->setEnabled(false); | 910 | toBeginningButton->setEnabled(false); |
980 | toEndButton->setEnabled(false); | 911 | toEndButton->setEnabled(false); |
@@ -1011,6 +942,6 @@ void QtRec::thisTab(QWidget* widg) { | |||
1011 | int index=TabWidget->currentPageIndex(); | 942 | int index=TabWidget->currentPageIndex(); |
1012 | 943 | ||
1013 | if(index==0) { //file page | 944 | // if(index==0) { //file page |
1014 | } | 945 | // } |
1015 | 946 | ||
1016 | if(index ==1) { //control page | 947 | if(index ==1) { //control page |
@@ -1020,6 +951,6 @@ void QtRec::thisTab(QWidget* widg) { | |||
1020 | } | 951 | } |
1021 | 952 | ||
1022 | if(index==2) { //help page | 953 | // if(index==2) { //help page |
1023 | } | 954 | // } |
1024 | qApp->processEvents(); | 955 | qApp->processEvents(); |
1025 | update(); | 956 | update(); |
@@ -1029,5 +960,4 @@ void QtRec::thisTab(QWidget* widg) { | |||
1029 | void QtRec::getOutVol( ) { | 960 | void QtRec::getOutVol( ) { |
1030 | filePara.outVol = soundDevice->getOutVolume(); | 961 | filePara.outVol = soundDevice->getOutVolume(); |
1031 | qDebug("out vol %d", filePara.outVol); | ||
1032 | OutputSlider->setValue( -filePara.outVol); | 962 | OutputSlider->setValue( -filePara.outVol); |
1033 | } | 963 | } |
@@ -1035,5 +965,4 @@ void QtRec::getOutVol( ) { | |||
1035 | void QtRec::getInVol() { | 965 | void QtRec::getInVol() { |
1036 | filePara.inVol = soundDevice->getInVolume(); | 966 | filePara.inVol = soundDevice->getInVolume(); |
1037 | qDebug("in vol %d", filePara.inVol); | ||
1038 | InputSlider->setValue( -filePara.inVol); | 967 | InputSlider->setValue( -filePara.inVol); |
1039 | } | 968 | } |
@@ -1056,5 +985,4 @@ bool QtRec::setupAudio( bool b) { | |||
1056 | 985 | ||
1057 | if( !b){ // we want to play | 986 | if( !b){ // we want to play |
1058 | qDebug("setting up DSP for playing"); | ||
1059 | if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) { | 987 | if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) { |
1060 | sampleformat = AFMT_S16_LE; | 988 | sampleformat = AFMT_S16_LE; |
@@ -1070,5 +998,4 @@ bool QtRec::setupAudio( bool b) { | |||
1070 | mixerString = DSPSTRMIXEROUT; | 998 | mixerString = DSPSTRMIXEROUT; |
1071 | } else { // we want to record | 999 | } else { // we want to record |
1072 | qDebug("setting up DSP for recording"); | ||
1073 | 1000 | ||
1074 | if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16") | 1001 | if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16") |
@@ -1079,15 +1006,11 @@ bool QtRec::setupAudio( bool b) { | |||
1079 | if( !compressionCheckBox->isChecked()) { | 1006 | if( !compressionCheckBox->isChecked()) { |
1080 | filePara.format=WAVE_FORMAT_PCM; | 1007 | filePara.format=WAVE_FORMAT_PCM; |
1081 | qDebug("WAVE_FORMAT_PCM"); | ||
1082 | } else { | 1008 | } else { |
1083 | filePara.format=WAVE_FORMAT_DVI_ADPCM; | 1009 | filePara.format=WAVE_FORMAT_DVI_ADPCM; |
1084 | sampleformat=AFMT_S16_LE; | 1010 | sampleformat=AFMT_S16_LE; |
1085 | qDebug("WAVE_FORMAT_DVI_ADPCM"); | ||
1086 | } | 1011 | } |
1087 | 1012 | ||
1088 | stereo = filePara.channels = 1; | 1013 | stereo = filePara.channels = 1; |
1089 | // filePara.sampleRate = sampleRateComboBox->currentText().toInt( &ok,10);//44100; | ||
1090 | flags= O_RDWR; | 1014 | flags= O_RDWR; |
1091 | // flags= O_RDONLY; | ||
1092 | dspString = DSPSTRIN; | 1015 | dspString = DSPSTRIN; |
1093 | mixerString = DSPSTRMIXEROUT; | 1016 | mixerString = DSPSTRMIXEROUT; |
@@ -1095,12 +1018,8 @@ bool QtRec::setupAudio( bool b) { | |||
1095 | 1018 | ||
1096 | // if(soundDevice) delete soundDevice; | 1019 | // if(soundDevice) delete soundDevice; |
1097 | qDebug("<<<<<<<<<<<<<<<<<<<open dsp %d %d %d", filePara.sampleRate, filePara.channels, sampleformat); | ||
1098 | soundDevice = new Device( this, dspString, mixerString, b); | 1020 | soundDevice = new Device( this, dspString, mixerString, b); |
1099 | // soundDevice->openDsp(); | 1021 | // soundDevice->openDsp(); |
1100 | soundDevice->reset(); | 1022 | soundDevice->reset(); |
1101 | 1023 | ||
1102 | qDebug("device has been made %d", soundDevice->sd); | ||
1103 | |||
1104 | ////////////////// <<<<<<<<<<<<>>>>>>>>>>>> | ||
1105 | soundDevice->setDeviceFormat( sampleformat); | 1024 | soundDevice->setDeviceFormat( sampleformat); |
1106 | soundDevice->setDeviceChannels( filePara.channels); | 1025 | soundDevice->setDeviceChannels( filePara.channels); |
@@ -1112,13 +1031,12 @@ bool QtRec::setupAudio( bool b) { | |||
1112 | soundDevice->getDeviceFragSize(); | 1031 | soundDevice->getDeviceFragSize(); |
1113 | #endif | 1032 | #endif |
1114 | ///////////////// | 1033 | |
1115 | filePara.sd = soundDevice->sd; | 1034 | filePara.sd = soundDevice->sd; |
1116 | 1035 | ||
1117 | if ( filePara.sd == -1) { | 1036 | if ( filePara.sd == -1) { |
1118 | |||
1119 | monitoring=false; | 1037 | monitoring=false; |
1120 | stopped=true; | 1038 | stopped=true; |
1121 | update(); | 1039 | update(); |
1122 | setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); | 1040 | setCaption( tr( "OpieRecord " ) /*+ QString::number(VERSION)*/ ); |
1123 | stopped=true; | 1041 | stopped=true; |
1124 | return false; | 1042 | return false; |
@@ -1132,5 +1050,5 @@ bool QtRec::setupAudio( bool b) { | |||
1132 | 1050 | ||
1133 | bool QtRec::setUpFile() { //setup file for recording | 1051 | bool QtRec::setUpFile() { //setup file for recording |
1134 | qDebug("Setting up wavfile"); | 1052 | // qDebug("Setting up wavfile"); |
1135 | // if(wavFile) delete wavFile; | 1053 | // if(wavFile) delete wavFile; |
1136 | wavFile = new WavFile( this, (const QString &)"", | 1054 | wavFile = new WavFile( this, (const QString &)"", |
@@ -1161,5 +1079,5 @@ bool QtRec::doPlay() { | |||
1161 | // int number=0; | 1079 | // int number=0; |
1162 | if( !paused) { | 1080 | if( !paused) { |
1163 | qDebug("new"); | 1081 | // qDebug("new"); |
1164 | total=0; | 1082 | total=0; |
1165 | bytesWritten=0; | 1083 | bytesWritten=0; |
@@ -1174,14 +1092,13 @@ bool QtRec::doPlay() { | |||
1174 | QString num; | 1092 | QString num; |
1175 | // block=BUFSIZE; | 1093 | // block=BUFSIZE; |
1176 | qDebug("Play number of samples %d", filePara.numberSamples); | ||
1177 | timeSlider->setRange(0, filePara.numberSamples); | 1094 | timeSlider->setRange(0, filePara.numberSamples); |
1178 | timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds); | 1095 | timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds); |
1179 | timeLabel->setText( timeString+ tr(" seconds")); | 1096 | timeLabel->setText( timeString+ tr(" seconds")); |
1180 | 1097 | ||
1181 | if( filePara.format==WAVE_FORMAT_DVI_ADPCM) { | 1098 | // if( filePara.format==WAVE_FORMAT_DVI_ADPCM) { |
1182 | qDebug("WAVE_FORMAT_DVI_ADPCM"); | 1099 | // // qDebug("WAVE_FORMAT_DVI_ADPCM"); |
1183 | } else { | 1100 | // } else { |
1184 | qDebug("WAVE_FORMAT_PCM"); | 1101 | // // qDebug("WAVE_FORMAT_PCM"); |
1185 | } | 1102 | // } |
1186 | QString msg; | 1103 | QString msg; |
1187 | msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); | 1104 | msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); |
@@ -1190,5 +1107,5 @@ bool QtRec::doPlay() { | |||
1190 | #endif | 1107 | #endif |
1191 | if( filePara.resolution == 16 ) { //AFMT_S16_LE) { | 1108 | if( filePara.resolution == 16 ) { //AFMT_S16_LE) { |
1192 | qDebug("16 bit"); | 1109 | // qDebug("16 bit"); |
1193 | 1110 | ||
1194 | startTimer(1000); | 1111 | startTimer(1000); |
@@ -1278,5 +1195,5 @@ bool QtRec::doPlay() { | |||
1278 | } //end loop | 1195 | } //end loop |
1279 | } else { /////////////////////////////// format = AFMT_U8; | 1196 | } else { /////////////////////////////// format = AFMT_U8; |
1280 | unsigned char unsigned_inbuffer[BUFSIZE], unsigned_outbuffer[BUFSIZE]; | 1197 | unsigned char unsigned_inbuffer[BUFSIZE];//, unsigned_outbuffer[BUFSIZE]; |
1281 | memset( unsigned_inbuffer,0,BUFSIZE); | 1198 | memset( unsigned_inbuffer,0,BUFSIZE); |
1282 | for(;;) { // main loop | 1199 | for(;;) { // main loop |
@@ -1344,5 +1261,5 @@ void QtRec::changesamplerateCombo(int i) { | |||
1344 | // soundDevice=0; | 1261 | // soundDevice=0; |
1345 | // delete soundDevice; | 1262 | // delete soundDevice; |
1346 | qDebug("Change sample rate %d", rate); | 1263 | // qDebug("Change sample rate %d", rate); |
1347 | cfg.write(); | 1264 | cfg.write(); |
1348 | 1265 | ||
@@ -1365,5 +1282,5 @@ void QtRec::changeDirCombo(int index) { | |||
1365 | recDir = path; | 1282 | recDir = path; |
1366 | cfg.writeEntry("directory", recDir); | 1283 | cfg.writeEntry("directory", recDir); |
1367 | qDebug("new rec dir "+recDir); | 1284 | // qDebug("new rec dir "+recDir); |
1368 | } | 1285 | } |
1369 | } | 1286 | } |
@@ -1380,8 +1297,8 @@ void QtRec::changeSizeLimitCombo(int) { | |||
1380 | 1297 | ||
1381 | void QtRec::newSound() { | 1298 | void QtRec::newSound() { |
1382 | qDebug("<<<<<<<<<new sound"); | 1299 | // qDebug("<<<<<<<<<new sound"); |
1383 | 1300 | ||
1384 | if( !rec()) { | 1301 | if( !rec()) { |
1385 | qDebug("rec() failed"); | 1302 | // qDebug("rec() failed"); |
1386 | endRecording(); | 1303 | endRecording(); |
1387 | deleteSound(); | 1304 | deleteSound(); |
@@ -1449,5 +1366,5 @@ void QtRec::deleteSound() { | |||
1449 | }; | 1366 | }; |
1450 | #endif | 1367 | #endif |
1451 | setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); | 1368 | setCaption( tr( "OpieRecord " ) /*+ QString::number(VERSION)*/ ); |
1452 | 1369 | ||
1453 | } | 1370 | } |
@@ -1514,5 +1431,5 @@ void QtRec::keyPressEvent( QKeyEvent *e) { | |||
1514 | break; | 1431 | break; |
1515 | case Key_Left: { | 1432 | case Key_Left: { |
1516 | qDebug("rewinding"); | 1433 | // qDebug("rewinding"); |
1517 | if( !e->isAutoRepeat()) | 1434 | if( !e->isAutoRepeat()) |
1518 | rewindPressed(); | 1435 | rewindPressed(); |
@@ -1568,5 +1485,5 @@ void QtRec::keyReleaseEvent( QKeyEvent *e) { | |||
1568 | case Key_Up: | 1485 | case Key_Up: |
1569 | // stop(); | 1486 | // stop(); |
1570 | qDebug("Up"); | 1487 | // qDebug("Up"); |
1571 | break; | 1488 | break; |
1572 | case Key_Down: | 1489 | case Key_Down: |
@@ -1576,9 +1493,9 @@ void QtRec::keyReleaseEvent( QKeyEvent *e) { | |||
1576 | break; | 1493 | break; |
1577 | case Key_Left: | 1494 | case Key_Left: |
1578 | qDebug("Left"); | 1495 | // qDebug("Left"); |
1579 | rewindReleased(); | 1496 | rewindReleased(); |
1580 | break; | 1497 | break; |
1581 | case Key_Right: | 1498 | case Key_Right: |
1582 | qDebug("Right"); | 1499 | // qDebug("Right"); |
1583 | FastforwardReleased(); | 1500 | FastforwardReleased(); |
1584 | break; | 1501 | break; |
@@ -1587,5 +1504,5 @@ void QtRec::keyReleaseEvent( QKeyEvent *e) { | |||
1587 | 1504 | ||
1588 | void QtRec::endRecording() { | 1505 | void QtRec::endRecording() { |
1589 | qDebug("endRecording"); | 1506 | // qDebug("endRecording"); |
1590 | setRecordButton(false); | 1507 | setRecordButton(false); |
1591 | timeSlider->setValue(0); | 1508 | timeSlider->setValue(0); |
@@ -1618,9 +1535,9 @@ void QtRec::endRecording() { | |||
1618 | QString cmd; | 1535 | QString cmd; |
1619 | cmd.sprintf("mv "+ wavFile->trackName() + " " + wavFile->currentFileName); | 1536 | cmd.sprintf("mv "+ wavFile->trackName() + " " + wavFile->currentFileName); |
1620 | qDebug("moving tmp file to "+currentFileName); | 1537 | // qDebug("moving tmp file to "+currentFileName); |
1621 | system(cmd.latin1()); | 1538 | system(cmd.latin1()); |
1622 | } | 1539 | } |
1623 | 1540 | ||
1624 | qDebug("Just moved "+wavFile->currentFileName); | 1541 | // qDebug("Just moved "+wavFile->currentFileName); |
1625 | Config cfg("OpieRec"); | 1542 | Config cfg("OpieRec"); |
1626 | cfg.setGroup("Sounds"); | 1543 | cfg.setGroup("Sounds"); |
@@ -1638,8 +1555,8 @@ void QtRec::endRecording() { | |||
1638 | time.sprintf("%.2f", filePara.numberOfRecordedSeconds); | 1555 | time.sprintf("%.2f", filePara.numberOfRecordedSeconds); |
1639 | cfg.writeEntry( wavFile->currentFileName, time ); | 1556 | cfg.writeEntry( wavFile->currentFileName, time ); |
1640 | qDebug("writing config numberOfRecordedSeconds "+time); | 1557 | // qDebug("writing config numberOfRecordedSeconds "+time); |
1641 | 1558 | ||
1642 | cfg.write(); | 1559 | cfg.write(); |
1643 | qDebug("finished recording"); | 1560 | // qDebug("finished recording"); |
1644 | timeLabel->setText(""); | 1561 | timeLabel->setText(""); |
1645 | } | 1562 | } |
@@ -1653,5 +1570,5 @@ void QtRec::endRecording() { | |||
1653 | void QtRec::endPlaying() { | 1570 | void QtRec::endPlaying() { |
1654 | 1571 | ||
1655 | qDebug("end playing"); | 1572 | // qDebug("end playing"); |
1656 | setRecordButton(false); | 1573 | setRecordButton(false); |
1657 | 1574 | ||
@@ -1665,5 +1582,5 @@ void QtRec::endPlaying() { | |||
1665 | soundDevice->sd=-1; | 1582 | soundDevice->sd=-1; |
1666 | // if(soundDevice) delete soundDevice; | 1583 | // if(soundDevice) delete soundDevice; |
1667 | qDebug("file and sound device closed"); | 1584 | // qDebug("file and sound device closed"); |
1668 | stopped=true; | 1585 | stopped=true; |
1669 | recording=false; | 1586 | recording=false; |
@@ -1678,5 +1595,5 @@ void QtRec::endPlaying() { | |||
1678 | // if(wavFile) delete wavFile; //this crashes | 1595 | // if(wavFile) delete wavFile; //this crashes |
1679 | 1596 | ||
1680 | qDebug("track closed"); | 1597 | // qDebug("track closed"); |
1681 | timeSlider->setValue(0); | 1598 | timeSlider->setValue(0); |
1682 | 1599 | ||
@@ -1700,5 +1617,5 @@ bool QtRec::openPlayFile() { | |||
1700 | if( cfg.readEntry( QString::number(i),"").find( currentFile,0,true) != -1) { | 1617 | if( cfg.readEntry( QString::number(i),"").find( currentFile,0,true) != -1) { |
1701 | currentFileName=cfg.readEntry( currentFile, "" ); | 1618 | currentFileName=cfg.readEntry( currentFile, "" ); |
1702 | qDebug("opening for play: "+currentFileName); | 1619 | // qDebug("opening for play: "+currentFileName); |
1703 | } | 1620 | } |
1704 | } | 1621 | } |
@@ -1711,5 +1628,5 @@ bool QtRec::openPlayFile() { | |||
1711 | QString errorMsg=(QString)strerror(errno); | 1628 | QString errorMsg=(QString)strerror(errno); |
1712 | monitoring=false; | 1629 | monitoring=false; |
1713 | setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); | 1630 | setCaption( tr( "OpieRecord " )/* + QString::number(VERSION)*/ ); |
1714 | QMessageBox::message(tr("Note"),tr("Could not open audio file.\n") | 1631 | QMessageBox::message(tr("Note"),tr("Could not open audio file.\n") |
1715 | +errorMsg+"\n"+currentFile); | 1632 | +errorMsg+"\n"+currentFile); |
@@ -1822,6 +1739,6 @@ void QtRec::doRename() { | |||
1822 | 1739 | ||
1823 | void QtRec::okRename() { | 1740 | void QtRec::okRename() { |
1824 | qDebug("okRename"); | 1741 | // qDebug("okRename"); |
1825 | qDebug(renameBox->text()); | 1742 | // qDebug(renameBox->text()); |
1826 | QString filename = renameBox->text(); | 1743 | QString filename = renameBox->text(); |
1827 | cancelRename(); | 1744 | cancelRename(); |
@@ -1835,5 +1752,5 @@ void QtRec::okRename() { | |||
1835 | QString file = ListView1->currentItem()->text(0); | 1752 | QString file = ListView1->currentItem()->text(0); |
1836 | 1753 | ||
1837 | qDebug("filename is " + filename); | 1754 | // qDebug("filename is " + filename); |
1838 | 1755 | ||
1839 | int nFiles = cfg.readNumEntry("NumberofFiles",0); | 1756 | int nFiles = cfg.readNumEntry("NumberofFiles",0); |
@@ -1859,5 +1776,5 @@ void QtRec::okRename() { | |||
1859 | 1776 | ||
1860 | void QtRec::cancelRename() { | 1777 | void QtRec::cancelRename() { |
1861 | qDebug("cancel rename"); | 1778 | // qDebug("cancel rename"); |
1862 | bool resetFocus = ListView1->viewport()->focusProxy() == renameBox; | 1779 | bool resetFocus = ListView1->viewport()->focusProxy() == renameBox; |
1863 | delete renameBox; | 1780 | delete renameBox; |
@@ -1895,5 +1812,5 @@ int QtRec::getCurrentSizeLimit() { | |||
1895 | 1812 | ||
1896 | void QtRec::timerBreak() { | 1813 | void QtRec::timerBreak() { |
1897 | qDebug("timer break"); | 1814 | // qDebug("timer break"); |
1898 | stop(); | 1815 | stop(); |
1899 | } | 1816 | } |
@@ -1962,6 +1879,6 @@ long QtRec::checkDiskSpace(const QString &path) { | |||
1962 | // char f_fpack[6]; /* Pack name */ | 1879 | // char f_fpack[6]; /* Pack name */ |
1963 | 1880 | ||
1964 | void QtRec::receive( const QCString &msg, const QByteArray & ) { | 1881 | void QtRec::receive( const QCString &/* msg*/, const QByteArray & ) { |
1965 | qDebug("Voicerecord received message "+msg); | 1882 | // qDebug("Voicerecord received message "+msg); |
1966 | 1883 | ||
1967 | } | 1884 | } |
@@ -2228,17 +2145,14 @@ long findPeak(long input ) { | |||
2228 | 2145 | ||
2229 | // halfLife = time in seconds for output to decay to half value after an impulse | 2146 | // halfLife = time in seconds for output to decay to half value after an impulse |
2230 | static float output = 0.0; | 2147 | float output = 0.0; |
2231 | int halfLife = .25; | 2148 | float halfLife = .25; |
2232 | float vsf = .0025; | 2149 | float vsf = .0025; |
2233 | float scalar = pow( 0.5, 1.0/(halfLife * filePara.sampleRate )); | 2150 | float scalar = pow( 0.5, 1.0/(halfLife * filePara.sampleRate )); |
2234 | if( input < 0.0 ) | 2151 | if( input < 0.0 ) |
2235 | input = -input; // Absolute value. | 2152 | input = -input; // Absolute value. |
2236 | if ( input >= output ) | 2153 | if ( input >= output) { |
2237 | { | ||
2238 | // When we hit a peak, ride the peak to the top. | 2154 | // When we hit a peak, ride the peak to the top. |
2239 | output = input; | 2155 | output = input; |
2240 | } | 2156 | } else { |
2241 | else | ||
2242 | { | ||
2243 | // Exponential decay of output when signal is low. | 2157 | // Exponential decay of output when signal is low. |
2244 | output = output * scalar; | 2158 | output = output * scalar; |
@@ -2251,4 +2165,4 @@ long findPeak(long input ) { | |||
2251 | } | 2165 | } |
2252 | 2166 | ||
2253 | return output; | 2167 | return (long)output; |
2254 | } | 2168 | } |
diff --git a/noncore/multimedia/opierec/qtrec.h b/noncore/multimedia/opierec/qtrec.h index bcf5504..7965c74 100644 --- a/noncore/multimedia/opierec/qtrec.h +++ b/noncore/multimedia/opierec/qtrec.h | |||
@@ -5,5 +5,5 @@ copyright 2002 by L.J. Potter ljp@llornkcor.com | |||
5 | #ifndef QTREC_H | 5 | #ifndef QTREC_H |
6 | #define QTREC_H | 6 | #define QTREC_H |
7 | #define VERSION 20021202 | 7 | #define VERSION 1.0 |
8 | 8 | ||
9 | #include <qpe/ir.h> | 9 | #include <qpe/ir.h> |