summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2003-08-10 23:03:39 (UTC)
committer llornkcor <llornkcor>2003-08-10 23:03:39 (UTC)
commit892aac84512b257c72362702a98462289589faec (patch) (unidiff)
treed514fbd450129f2a1b2a897ef06c93e27cde4b30
parent44bb1f23dcd0bea4775ba4b48fb370ad651290cc (diff)
downloadopie-892aac84512b257c72362702a98462289589faec.zip
opie-892aac84512b257c72362702a98462289589faec.tar.gz
opie-892aac84512b257c72362702a98462289589faec.tar.bz2
forgot what I changed, but I changed something I need to commit
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/multimedia/opierec/qtrec.cpp200
-rw-r--r--noncore/multimedia/opierec/qtrec.h2
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
@@ -107,11 +107,6 @@ int sd;
107void quickRec() { 107void 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;
117 112
@@ -127,26 +122,19 @@ void quickRec() {
127 122
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;
144 timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds); 133 timeString.sprintf("%.2f", filePara.numberOfRecordedSeconds);
145 timeLabel->setText( timeString+ " seconds"); 134 timeLabel->setText( timeString+ " seconds");
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];
152 short sbuf2[BUFSIZE]; 140 short sbuf2[BUFSIZE];
@@ -156,29 +144,22 @@ void quickRec() {
156 144
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 }
176 //if(stereo == 2) { 159 //if(stereo == 2) {
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++)
184 { //since Z is mono do normally 165 { //since Z is mono do normally
@@ -186,8 +167,6 @@ void quickRec() {
186 printf("peak %ld\r",peak); 167 printf("peak %ld\r",peak);
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)
193 // total += bytesWritten/2; //mono 172 // total += bytesWritten/2; //mono
@@ -200,17 +179,7 @@ void quickRec() {
200 timeSlider->setValue( total); 179 timeSlider->setValue( total);
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");
216 185
@@ -219,30 +188,23 @@ void quickRec() {
219 break; 188 break;
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);
226 memset( outbuffer,0,BUFSIZE); 194 memset( outbuffer,0,BUFSIZE);
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
246outbuffer[i]=inbuffer[i]>>1; // no clippy, please 208outbuffer[i]=inbuffer[i]>>1; // no clippy, please
247}*/ 209}*/
248 bytesWritten = ::write( filePara.fd , inbuffer, number); 210 bytesWritten = ::write( filePara.fd , inbuffer, number);
@@ -264,8 +226,6 @@ outbuffer[i]=inbuffer[i]>>1; // no clippy, please
264 printf("peak %ld\r",peak); 226 printf("peak %ld\r",peak);
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)
271 timeSlider->setValue( total); 231 timeSlider->setValue( total);
@@ -276,10 +236,8 @@ outbuffer[i]=inbuffer[i]>>1; // no clippy, please
276// qDebug("%d, %d", info.bytes, ( info.bytes / filePara.sampleRate) / 2); 236// qDebug("%d, %d", info.bytes, ( info.bytes / filePara.sampleRate) / 2);
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)
285 break; 243 break;
@@ -293,7 +251,7 @@ outbuffer[i]=inbuffer[i]>>1; // no clippy, please
293 251
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 }
299 number=::read( filePara.sd, unsigned_inbuffer, BUFSIZE); 257 number=::read( filePara.sd, unsigned_inbuffer, BUFSIZE);
@@ -348,19 +306,13 @@ void playIt() {
348 306
349} 307}
350 308
351
352
353/////////////////<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>> 309/////////////////<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>
354/////////////////<<<<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>
355
356QtRec::QtRec( QWidget* parent, const char* name, WFlags fl ) 310QtRec::QtRec( QWidget* parent, const char* name, WFlags fl )
357 : QWidget( parent, name, fl ) { 311 : QWidget( parent, name, fl ) {
358 // QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << true; // mute device 312 // QCopEnvelope( "QPE/System", "volumeChange(bool)" ) << true; // mute device
359 // autoMute=TRUE; 313 // autoMute=TRUE;
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" );
366 init(); 318 init();
@@ -411,7 +363,6 @@ void QtRec::cleanUp() {
411 363
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();
417} 368}
@@ -754,9 +705,10 @@ void QtRec::initIconView() {
754 QListViewItem * item; 705 QListViewItem * item;
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);
762 fileDate = info.lastModified().toString(); 714 fileDate = info.lastModified().toString();
@@ -859,7 +811,7 @@ void QtRec::initConfig() {
859//================ 811//================
860 812
861void QtRec::stop() { 813void QtRec::stop() {
862 qDebug("<<<<<<<<<stop()"); 814 // qDebug("<<<<<<<<<stop()");
863 setRecordButton(false); 815 setRecordButton(false);
864 monitoring=false; 816 monitoring=false;
865 stopped=true; 817 stopped=true;
@@ -887,7 +839,6 @@ void QtRec::doPlayBtn() {
887 839
888void QtRec::start() { //play 840void 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 );
893 Stop_PushButton->setDown(true); 844 Stop_PushButton->setDown(true);
@@ -902,13 +853,10 @@ void QtRec::start() { //play
902} 853}
903 854
904bool QtRec::rec() { //record 855bool 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"));
914 monitoring=false; 862 monitoring=false;
@@ -917,45 +865,30 @@ bool QtRec::rec() { //record
917 865
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
936 if( filePara.SecondsToRecord == 0) { 877 if( filePara.SecondsToRecord == 0) {
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;
946 } 885 }
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) {
961 QMessageBox::warning(this, 894 QMessageBox::warning(this,
@@ -971,11 +904,9 @@ bool QtRec::rec() { //record
971 setCaption( msg); 904 setCaption( msg);
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);
981 912
@@ -1010,8 +941,8 @@ void QtRec::thisTab(QWidget* widg) {
1010 if(widg != NULL) { 941 if(widg != NULL) {
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
1017 fillDirectoryCombo(); 948 fillDirectoryCombo();
@@ -1019,8 +950,8 @@ void QtRec::thisTab(QWidget* widg) {
1019// soundDevice->getInVol(); 950// soundDevice->getInVol();
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();
1026 } 957 }
@@ -1028,13 +959,11 @@ void QtRec::thisTab(QWidget* widg) {
1028 959
1029void QtRec::getOutVol( ) { 960void 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}
1034 964
1035void QtRec::getInVol() { 965void 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}
1040 969
@@ -1055,7 +984,6 @@ bool QtRec::setupAudio( bool b) {
1055 filePara.resolution = bitRateComboBox->currentText().toInt( &ok,10); //16 984 filePara.resolution = bitRateComboBox->currentText().toInt( &ok,10); //16
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;
1061 filePara.resolution = 16; 989 filePara.resolution = 16;
@@ -1069,7 +997,6 @@ bool QtRec::setupAudio( bool b) {
1069 dspString = DSPSTROUT; 997 dspString = DSPSTROUT;
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")
1075 sampleformat = AFMT_S16_LE; 1002 sampleformat = AFMT_S16_LE;
@@ -1078,30 +1005,22 @@ bool QtRec::setupAudio( bool b) {
1078 1005
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;
1094 } 1017 }
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);
1107 soundDevice->setDeviceRate( filePara.sampleRate); 1026 soundDevice->setDeviceRate( filePara.sampleRate);
@@ -1111,15 +1030,14 @@ bool QtRec::setupAudio( bool b) {
1111 soundDevice->setFragSize( frag); 1030 soundDevice->setFragSize( frag);
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;
1125 } 1043 }
@@ -1131,7 +1049,7 @@ bool QtRec::setupAudio( bool b) {
1131 1049
1132 1050
1133bool QtRec::setUpFile() { //setup file for recording 1051bool 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 &)"",
1137 true, 1055 true,
@@ -1160,7 +1078,7 @@ bool QtRec::doPlay() {
1160 recording = false; 1078 recording = false;
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;
1166 filePara.numberOfRecordedSeconds = 0; 1084 filePara.numberOfRecordedSeconds = 0;
@@ -1173,23 +1091,22 @@ bool QtRec::doPlay() {
1173 1091
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);
1188#ifdef DEV_VERSION 1105#ifdef DEV_VERSION
1189 setCaption( msg); 1106 setCaption( msg);
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);
1195 1112
@@ -1277,7 +1194,7 @@ bool QtRec::doPlay() {
1277// fflush(stdout); 1194// fflush(stdout);
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
1283 if (stopped) 1200 if (stopped)
@@ -1343,7 +1260,7 @@ void QtRec::changesamplerateCombo(int i) {
1343// soundDevice->closeDevice( true); 1260// soundDevice->closeDevice( true);
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
1349} 1266}
@@ -1364,7 +1281,7 @@ void QtRec::changeDirCombo(int index) {
1364 const QString path = (*it)->path(); 1281 const QString path = (*it)->path();
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 }
1370 cfg.write(); 1287 cfg.write();
@@ -1379,10 +1296,10 @@ void QtRec::changeSizeLimitCombo(int) {
1379} 1296}
1380 1297
1381void QtRec::newSound() { 1298void 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();
1388 } 1305 }
@@ -1448,7 +1365,7 @@ void QtRec::deleteSound() {
1448#ifndef DEV_VERSION 1365#ifndef DEV_VERSION
1449 }; 1366 };
1450#endif 1367#endif
1451 setCaption( tr( "OpieRecord " ) + QString::number(VERSION) ); 1368 setCaption( tr( "OpieRecord " ) /*+ QString::number(VERSION)*/ );
1452 1369
1453} 1370}
1454 1371
@@ -1513,7 +1430,7 @@ void QtRec::keyPressEvent( QKeyEvent *e) {
1513 // newSound(); 1430 // newSound();
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();
1519 } 1436 }
@@ -1567,7 +1484,7 @@ void QtRec::keyReleaseEvent( QKeyEvent *e) {
1567 break; 1484 break;
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:
1573 // start(); 1490 // start();
@@ -1575,18 +1492,18 @@ void QtRec::keyReleaseEvent( QKeyEvent *e) {
1575 // newSound(); 1492 // newSound();
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;
1585 } 1502 }
1586} 1503}
1587 1504
1588void QtRec::endRecording() { 1505void QtRec::endRecording() {
1589 qDebug("endRecording"); 1506 // qDebug("endRecording");
1590 setRecordButton(false); 1507 setRecordButton(false);
1591 timeSlider->setValue(0); 1508 timeSlider->setValue(0);
1592 toBeginningButton->setEnabled(true); 1509 toBeginningButton->setEnabled(true);
@@ -1617,11 +1534,11 @@ void QtRec::endRecording() {
1617// move tmp file to regular file 1534// move tmp file to regular file
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");
1627 1544
@@ -1637,10 +1554,10 @@ void QtRec::endRecording() {
1637 QString time; 1554 QString time;
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 }
1646 1563
@@ -1652,7 +1569,7 @@ void QtRec::endRecording() {
1652 1569
1653void QtRec::endPlaying() { 1570void QtRec::endPlaying() {
1654 1571
1655 qDebug("end playing"); 1572 // qDebug("end playing");
1656 setRecordButton(false); 1573 setRecordButton(false);
1657 1574
1658 toBeginningButton->setEnabled(true); 1575 toBeginningButton->setEnabled(true);
@@ -1664,7 +1581,7 @@ void QtRec::endPlaying() {
1664 soundDevice->closeDevice( false); 1581 soundDevice->closeDevice( false);
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;
1670 playing=false; 1587 playing=false;
@@ -1677,7 +1594,7 @@ void QtRec::endPlaying() {
1677 filePara.fd=0; 1594 filePara.fd=0;
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
1683 if(soundDevice) delete soundDevice; 1600 if(soundDevice) delete soundDevice;
@@ -1699,7 +1616,7 @@ bool QtRec::openPlayFile() {
1699 for(int i=0;i<nFiles+1;i++) { //look for file 1616 for(int i=0;i<nFiles+1;i++) { //look for file
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 }
1705 wavFile = new WavFile(this, 1622 wavFile = new WavFile(this,
@@ -1710,7 +1627,7 @@ bool QtRec::openPlayFile() {
1710 // if(!track.open(IO_ReadOnly)) { 1627 // if(!track.open(IO_ReadOnly)) {
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);
1716 return false; 1633 return false;
@@ -1821,8 +1738,8 @@ void QtRec::doRename() {
1821} 1738}
1822 1739
1823void QtRec::okRename() { 1740void 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();
1828 1745
@@ -1834,7 +1751,7 @@ void QtRec::okRename() {
1834 1751
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);
1840 1757
@@ -1858,7 +1775,7 @@ void QtRec::okRename() {
1858} 1775}
1859 1776
1860void QtRec::cancelRename() { 1777void 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;
1864 renameBox = 0; 1781 renameBox = 0;
@@ -1894,7 +1811,7 @@ int QtRec::getCurrentSizeLimit() {
1894} 1811}
1895 1812
1896void QtRec::timerBreak() { 1813void QtRec::timerBreak() {
1897 qDebug("timer break"); 1814 // qDebug("timer break");
1898 stop(); 1815 stop();
1899} 1816}
1900 1817
@@ -1961,8 +1878,8 @@ long QtRec::checkDiskSpace(const QString &path) {
1961// char f_fname[6]; /* Volumename */ 1878// char f_fname[6]; /* Volumename */
1962// char f_fpack[6]; /* Pack name */ 1879// char f_fpack[6]; /* Pack name */
1963 1880
1964void QtRec::receive( const QCString &msg, const QByteArray & ) { 1881void QtRec::receive( const QCString &/* msg*/, const QByteArray & ) {
1965 qDebug("Voicerecord received message "+msg); 1882 // qDebug("Voicerecord received message "+msg);
1966 1883
1967} 1884}
1968 1885
@@ -2227,19 +2144,16 @@ void QtRec::selectItemByName(const QString & name) {
2227long findPeak(long input ) { 2144long 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;
2245// 2159//
@@ -2250,5 +2164,5 @@ long findPeak(long input ) {
2250 if( output < vsf ) output = 0.0; 2164 if( output < vsf ) output = 0.0;
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
@@ -4,7 +4,7 @@ copyright 2002 by L.J. Potter ljp@llornkcor.com
4****************************************************************************/ 4****************************************************************************/
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>
10 10