-rw-r--r-- | noncore/multimedia/opierec/qtrec.cpp | 35 | ||||
-rw-r--r-- | noncore/multimedia/opierec/qtrec.h | 13 | ||||
-rw-r--r-- | noncore/multimedia/opierec/wavFile.cpp | 36 |
3 files changed, 40 insertions, 44 deletions
diff --git a/noncore/multimedia/opierec/qtrec.cpp b/noncore/multimedia/opierec/qtrec.cpp index 9b761aa..9d3d5cf 100644 --- a/noncore/multimedia/opierec/qtrec.cpp +++ b/noncore/multimedia/opierec/qtrec.cpp | |||
@@ -627,876 +627,863 @@ void QtRec::init() { | |||
627 | QHBoxLayout *Layout19a; | 627 | QHBoxLayout *Layout19a; |
628 | Layout19a = new QHBoxLayout( tab_5); | 628 | Layout19a = new QHBoxLayout( tab_5); |
629 | Layout19a->setSpacing( 2 ); | 629 | Layout19a->setSpacing( 2 ); |
630 | Layout19a->setMargin( 0 ); | 630 | Layout19a->setMargin( 0 ); |
631 | 631 | ||
632 | Layout15 = new QVBoxLayout( this); | 632 | Layout15 = new QVBoxLayout( this); |
633 | Layout15->setSpacing( 2 ); | 633 | Layout15->setSpacing( 2 ); |
634 | Layout15->setMargin( 0 ); | 634 | Layout15->setMargin( 0 ); |
635 | 635 | ||
636 | Layout15b = new QVBoxLayout( this); | 636 | Layout15b = new QVBoxLayout( this); |
637 | Layout15b->setSpacing( 2 ); | 637 | Layout15b->setSpacing( 2 ); |
638 | Layout15b->setMargin( 0 ); | 638 | Layout15b->setMargin( 0 ); |
639 | 639 | ||
640 | TextLabel2 = new QLabel( tab_5, "InputLabel" ); | 640 | TextLabel2 = new QLabel( tab_5, "InputLabel" ); |
641 | TextLabel2->setText( tr( "In")); | 641 | TextLabel2->setText( tr( "In")); |
642 | TextLabel2->setFixedWidth( 35); | 642 | TextLabel2->setFixedWidth( 35); |
643 | Layout15->addWidget( TextLabel2 ); | 643 | Layout15->addWidget( TextLabel2 ); |
644 | 644 | ||
645 | TextLabel3 = new QLabel( tab_5, "OutputLabel" ); | 645 | TextLabel3 = new QLabel( tab_5, "OutputLabel" ); |
646 | TextLabel3->setText( tr( "Out" ) ); | 646 | TextLabel3->setText( tr( "Out" ) ); |
647 | Layout15b->addWidget( TextLabel3 ); | 647 | Layout15b->addWidget( TextLabel3 ); |
648 | 648 | ||
649 | InputSlider = new QSlider( -100, 0, 10, 0, QSlider::Vertical, tab_5, (const char *) "InputSlider" ); | 649 | InputSlider = new QSlider( -100, 0, 10, 0, QSlider::Vertical, tab_5, (const char *) "InputSlider" ); |
650 | InputSlider->setTickmarks( QSlider::Both); | 650 | InputSlider->setTickmarks( QSlider::Both); |
651 | Layout15->addWidget( InputSlider); | 651 | Layout15->addWidget( InputSlider); |
652 | 652 | ||
653 | OutputSlider = new QSlider( -100,0,10,0, QSlider::Vertical,tab_5,(const char *) "OutputSlider" ); | 653 | OutputSlider = new QSlider( -100,0,10,0, QSlider::Vertical,tab_5,(const char *) "OutputSlider" ); |
654 | OutputSlider->setTickmarks( QSlider::Both); | 654 | OutputSlider->setTickmarks( QSlider::Both); |
655 | 655 | ||
656 | Layout15b->addWidget( OutputSlider ); | 656 | Layout15b->addWidget( OutputSlider ); |
657 | 657 | ||
658 | outMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 ); | 658 | outMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 ); |
659 | Layout15->addWidget( outMuteCheckBox ); | 659 | Layout15->addWidget( outMuteCheckBox ); |
660 | 660 | ||
661 | inMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 ); | 661 | inMuteCheckBox = new QCheckBox ( tr("mute"), tab_5 ); |
662 | inMuteCheckBox-> setFocusPolicy ( QWidget::NoFocus ); | 662 | inMuteCheckBox-> setFocusPolicy ( QWidget::NoFocus ); |
663 | Layout15b->addWidget( inMuteCheckBox ); | 663 | Layout15b->addWidget( inMuteCheckBox ); |
664 | 664 | ||
665 | 665 | ||
666 | Layout19a->addLayout( Layout15 ); | 666 | Layout19a->addLayout( Layout15 ); |
667 | Layout19a->addLayout( Layout15b ); | 667 | Layout19a->addLayout( Layout15b ); |
668 | 668 | ||
669 | fillDirectoryCombo(); | 669 | fillDirectoryCombo(); |
670 | 670 | ||
671 | TabWidget->insertTab( tab_3, tr( "Options" ) ); | 671 | TabWidget->insertTab( tab_3, tr( "Options" ) ); |
672 | 672 | ||
673 | TabWidget->insertTab( tab_5, tr( "Volume" ) ); | 673 | TabWidget->insertTab( tab_5, tr( "Volume" ) ); |
674 | 674 | ||
675 | waveform = new Waveform( this, "waveform" ); | 675 | waveform = new Waveform( this, "waveform" ); |
676 | waveform->setMinimumSize( QSize( 0, 50 ) ); | 676 | waveform->setMinimumSize( QSize( 0, 50 ) ); |
677 | 677 | ||
678 | layout->addMultiCellWidget( waveform, 8, 8, 0, 8); | 678 | layout->addMultiCellWidget( waveform, 8, 8, 0, 8); |
679 | waveform->setBackgroundColor ( black ); | 679 | waveform->setBackgroundColor ( black ); |
680 | } | 680 | } |
681 | 681 | ||
682 | void QtRec::initIconView() { | 682 | void QtRec::initIconView() { |
683 | ListView1->clear(); | 683 | ListView1->clear(); |
684 | Config cfg("OpieRec"); | 684 | Config cfg("OpieRec"); |
685 | cfg.setGroup("Sounds"); | 685 | cfg.setGroup("Sounds"); |
686 | QString temp; | 686 | QString temp; |
687 | QPixmap image0( ( const char** ) image0_data ); | 687 | QPixmap image0( ( const char** ) image0_data ); |
688 | 688 | ||
689 | int nFiles = cfg.readNumEntry("NumberofFiles",0); | 689 | int nFiles = cfg.readNumEntry("NumberofFiles",0); |
690 | // owarn << "init number of files " << nFiles << "" << oendl; | 690 | // owarn << "init number of files " << nFiles << "" << oendl; |
691 | 691 | ||
692 | for(int i = 1; i <= nFiles; i++) { | 692 | for(int i = 1; i <= nFiles; i++) { |
693 | 693 | ||
694 | QListViewItem * item; | 694 | QListViewItem * item; |
695 | QString fileS, mediaLocation, fileDate, filePath; | 695 | QString fileS, mediaLocation, fileDate, filePath; |
696 | 696 | ||
697 | temp.sprintf( "%d",i); | 697 | temp.sprintf( "%d",i); |
698 | temp = cfg.readEntry( temp,""); //reads currentFile | 698 | temp = cfg.readEntry( temp,""); //reads currentFile |
699 | filePath = cfg.readEntry( temp,""); //currentFileName | 699 | filePath = cfg.readEntry( temp,""); //currentFileName |
700 | 700 | ||
701 | QFileInfo info(filePath); | 701 | QFileInfo info(filePath); |
702 | fileDate = info.lastModified().toString(); | 702 | fileDate = info.lastModified().toString(); |
703 | 703 | ||
704 | fileS = cfg.readEntry( filePath, "0" );// file length in seconds | 704 | fileS = cfg.readEntry( filePath, "0" );// file length in seconds |
705 | mediaLocation = getStorage( filePath); | 705 | mediaLocation = getStorage( filePath); |
706 | if( info.exists()) { | 706 | if( info.exists()) { |
707 | // owarn << "new item " << temp << oendl; | 707 | // owarn << "new item " << temp << oendl; |
708 | item = new QListViewItem( ListView1, temp, fileS /*, mediaLocation, fileDate*/); | 708 | item = new QListViewItem( ListView1, temp, fileS /*, mediaLocation, fileDate*/); |
709 | item->setPixmap( 0, image0); | 709 | item->setPixmap( 0, image0); |
710 | if( currentFileName == filePath) | 710 | if( currentFileName == filePath) |
711 | ListView1->setSelected( item, true); | 711 | ListView1->setSelected( item, true); |
712 | } | 712 | } |
713 | } | 713 | } |
714 | } | 714 | } |
715 | 715 | ||
716 | void QtRec::initConnections() { | 716 | void QtRec::initConnections() { |
717 | connect(qApp,SIGNAL(aboutToQuit()),SLOT(cleanUp())); | 717 | connect(qApp,SIGNAL(aboutToQuit()),SLOT(cleanUp())); |
718 | 718 | ||
719 | connect(toBeginningButton,SIGNAL(pressed()),this,SLOT(rewindPressed())); | 719 | connect(toBeginningButton,SIGNAL(pressed()),this,SLOT(rewindPressed())); |
720 | connect(toBeginningButton,SIGNAL(released()),this,SLOT(rewindReleased())); | 720 | connect(toBeginningButton,SIGNAL(released()),this,SLOT(rewindReleased())); |
721 | connect(toEndButton,SIGNAL(pressed()),this,SLOT(FastforwardPressed())); | 721 | connect(toEndButton,SIGNAL(pressed()),this,SLOT(FastforwardPressed())); |
722 | connect(toEndButton,SIGNAL(released()),this,SLOT(FastforwardReleased())); | 722 | connect(toEndButton,SIGNAL(released()),this,SLOT(FastforwardReleased())); |
723 | |||
723 | connect(deleteSoundButton,SIGNAL(released()),this,SLOT(deleteSound())); | 724 | connect(deleteSoundButton,SIGNAL(released()),this,SLOT(deleteSound())); |
725 | |||
724 | connect(Stop_PushButton,SIGNAL(released()),this,SLOT(doPlayBtn())); | 726 | connect(Stop_PushButton,SIGNAL(released()),this,SLOT(doPlayBtn())); |
727 | // connect(Stop_PushButton,SIGNAL(released()),this,SLOT(doPlayBtn())); | ||
728 | |||
729 | // connect(Rec_PushButton,SIGNAL(released()),this,SIGNAL(startRecording())); | ||
725 | connect(Rec_PushButton,SIGNAL(released()),this,SLOT(newSound())); | 730 | connect(Rec_PushButton,SIGNAL(released()),this,SLOT(newSound())); |
726 | 731 | ||
727 | connect(TabWidget,SIGNAL(currentChanged(QWidget*)),this,SLOT(thisTab(QWidget*))); | 732 | connect(TabWidget,SIGNAL(currentChanged(QWidget*)),this,SLOT(thisTab(QWidget*))); |
728 | 733 | ||
729 | connect(OutputSlider,SIGNAL(sliderReleased()),this,SLOT(changedOutVolume())); | 734 | connect(OutputSlider,SIGNAL(sliderReleased()),this,SLOT(changedOutVolume())); |
730 | connect(InputSlider,SIGNAL(sliderReleased()),this,SLOT(changedInVolume())); | 735 | connect(InputSlider,SIGNAL(sliderReleased()),this,SLOT(changedInVolume())); |
731 | 736 | ||
732 | connect(sampleRateComboBox,SIGNAL(activated(int)),this,SLOT(changesamplerateCombo(int))); | 737 | connect(sampleRateComboBox,SIGNAL(activated(int)),this,SLOT(changesamplerateCombo(int))); |
733 | connect(bitRateComboBox,SIGNAL(activated(int)),this,SLOT(changebitrateCombo(int))); | 738 | connect(bitRateComboBox,SIGNAL(activated(int)),this,SLOT(changebitrateCombo(int))); |
734 | connect(directoryComboBox,SIGNAL(activated(int)),this,SLOT(changeDirCombo(int))); | 739 | connect(directoryComboBox,SIGNAL(activated(int)),this,SLOT(changeDirCombo(int))); |
735 | connect(sizeLimitCombo,SIGNAL(activated(int)),this,SLOT(changeSizeLimitCombo(int))); | 740 | connect(sizeLimitCombo,SIGNAL(activated(int)),this,SLOT(changeSizeLimitCombo(int))); |
736 | 741 | ||
737 | connect(stereoCheckBox,SIGNAL(toggled(bool)),this,SLOT(changeStereoCheck(bool))); | 742 | connect(stereoCheckBox,SIGNAL(toggled(bool)),this,SLOT(changeStereoCheck(bool))); |
738 | connect(outMuteCheckBox,SIGNAL(toggled(bool)),this,SLOT(doVolMuting(bool))); | 743 | connect(outMuteCheckBox,SIGNAL(toggled(bool)),this,SLOT(doVolMuting(bool))); |
739 | connect(inMuteCheckBox,SIGNAL(toggled(bool)),this,SLOT(doMicMuting(bool))); | 744 | connect(inMuteCheckBox,SIGNAL(toggled(bool)),this,SLOT(doMicMuting(bool))); |
740 | 745 | ||
741 | connect(ListView1,SIGNAL(doubleClicked(QListViewItem*)),this,SLOT(itClick(QListViewItem*))); | 746 | connect(ListView1,SIGNAL(doubleClicked(QListViewItem*)),this,SLOT(itClick(QListViewItem*))); |
742 | connect(ListView1,SIGNAL(mouseButtonPressed(int,QListViewItem*,const QPoint&,int)),this,SLOT(listPressed(int,QListViewItem*,const QPoint&,int))); | 747 | connect(ListView1,SIGNAL(mouseButtonPressed(int,QListViewItem*,const QPoint&,int)),this,SLOT(listPressed(int,QListViewItem*,const QPoint&,int))); |
743 | 748 | ||
744 | connect(timeSlider,SIGNAL(sliderMoved(int)),this,SLOT(changeTimeSlider(int))); | 749 | connect(timeSlider,SIGNAL(sliderMoved(int)),this,SLOT(changeTimeSlider(int))); |
745 | connect(timeSlider,SIGNAL(sliderPressed()),this,SLOT(timeSliderPressed())); | 750 | connect(timeSlider,SIGNAL(sliderPressed()),this,SLOT(timeSliderPressed())); |
746 | connect(timeSlider,SIGNAL(sliderReleased()),this,SLOT(timeSliderReleased())); | 751 | connect(timeSlider,SIGNAL(sliderReleased()),this,SLOT(timeSliderReleased())); |
747 | 752 | ||
748 | connect(compressionCheckBox,SIGNAL(toggled(bool)),this,SLOT(compressionSelected(bool))); | 753 | connect(compressionCheckBox,SIGNAL(toggled(bool)),this,SLOT(compressionSelected(bool))); |
749 | connect(autoMuteCheckBox,SIGNAL(toggled(bool)),this,SLOT(slotAutoMute(bool))); | 754 | connect(autoMuteCheckBox,SIGNAL(toggled(bool)),this,SLOT(slotAutoMute(bool))); |
750 | } | 755 | } |
751 | 756 | ||
752 | void QtRec::initConfig() { | 757 | void QtRec::initConfig() { |
753 | int index, fred, i; | 758 | int index, fred, i; |
754 | Config cfg("OpieRec"); | 759 | Config cfg("OpieRec"); |
755 | cfg.setGroup("Settings"); | 760 | cfg.setGroup("Settings"); |
756 | 761 | ||
757 | index = cfg.readNumEntry("samplerate",22050); | 762 | index = cfg.readNumEntry("samplerate",22050); |
758 | bool ok; | 763 | bool ok; |
759 | 764 | ||
760 | for(int ws=0;ws<sampleRateComboBox->count();ws++) { | 765 | for(int ws=0;ws<sampleRateComboBox->count();ws++) { |
761 | fred = sampleRateComboBox->text(ws).toInt(&ok, 10); | 766 | fred = sampleRateComboBox->text(ws).toInt(&ok, 10); |
762 | if( index == fred) { | 767 | if( index == fred) { |
763 | filePara.sampleRate = fred; | 768 | filePara.sampleRate = fred; |
764 | sampleRateComboBox->setCurrentItem(ws); | 769 | sampleRateComboBox->setCurrentItem(ws); |
765 | } | 770 | } |
766 | } | 771 | } |
767 | 772 | ||
768 | i = cfg.readNumEntry("bitrate",16); | 773 | i = cfg.readNumEntry("bitrate",16); |
769 | if(i == 16) | 774 | if(i == 16) |
770 | bitRateComboBox->setCurrentItem( 1); | 775 | bitRateComboBox->setCurrentItem( 1); |
771 | else if(i == 24) | 776 | else if(i == 24) |
772 | bitRateComboBox->setCurrentItem( 2); | 777 | bitRateComboBox->setCurrentItem( 2); |
773 | else if(i == 32) | 778 | else if(i == 32) |
774 | bitRateComboBox->setCurrentItem( 3); | 779 | bitRateComboBox->setCurrentItem( 3); |
775 | else | 780 | else |
776 | bitRateComboBox->setCurrentItem( 0); | 781 | bitRateComboBox->setCurrentItem( 0); |
777 | 782 | ||
778 | filePara.resolution = i; | 783 | filePara.resolution = i; |
779 | 784 | ||
780 | i = cfg.readNumEntry("sizeLimit", 5 ); | 785 | i = cfg.readNumEntry("sizeLimit", 5 ); |
781 | QString temp; | 786 | QString temp; |
782 | sizeLimitCombo->setCurrentItem((i/5)); | 787 | sizeLimitCombo->setCurrentItem((i/5)); |
783 | 788 | ||
784 | stereoCheckBox->setChecked( cfg.readBoolEntry("stereo", 1)); | 789 | stereoCheckBox->setChecked( cfg.readBoolEntry("stereo", 1)); |
785 | if( stereoCheckBox->isChecked()) { | 790 | if( stereoCheckBox->isChecked()) { |
786 | filePara.channels = 2; | 791 | filePara.channels = 2; |
787 | } else { | 792 | } else { |
788 | filePara.channels = 1; | 793 | filePara.channels = 1; |
789 | } | 794 | } |
790 | 795 | ||
791 | compressionCheckBox->setChecked( cfg.readBoolEntry("wavCompression",1)); | 796 | compressionCheckBox->setChecked( cfg.readBoolEntry("wavCompression",1)); |
792 | if( compressionCheckBox->isChecked()) { | 797 | if( compressionCheckBox->isChecked()) { |
793 | bitRateComboBox->setCurrentItem(1); | 798 | bitRateComboBox->setCurrentItem(1); |
794 | bitRateComboBox->setEnabled(false); | 799 | bitRateComboBox->setEnabled(false); |
795 | filePara.resolution=16; | 800 | filePara.resolution=16; |
796 | } | 801 | } |
797 | 802 | ||
798 | autoMuteCheckBox->setChecked( cfg.readBoolEntry("useAutoMute",0)); | 803 | autoMuteCheckBox->setChecked( cfg.readBoolEntry("useAutoMute",0)); |
799 | if( autoMuteCheckBox->isChecked()) | 804 | if( autoMuteCheckBox->isChecked()) |
800 | slotAutoMute(true); | 805 | slotAutoMute(true); |
801 | else | 806 | else |
802 | slotAutoMute(false); | 807 | slotAutoMute(false); |
803 | 808 | ||
804 | Config cofg( "qpe"); | 809 | Config cofg( "qpe"); |
805 | cofg.setGroup( "Volume"); | 810 | cofg.setGroup( "Volume"); |
806 | outMuteCheckBox->setChecked( cofg.readBoolEntry( "Mute",0)); | 811 | outMuteCheckBox->setChecked( cofg.readBoolEntry( "Mute",0)); |
807 | inMuteCheckBox->setChecked( cofg.readBoolEntry( "MicMute",0)); | 812 | inMuteCheckBox->setChecked( cofg.readBoolEntry( "MicMute",0)); |
808 | } | 813 | } |
809 | 814 | ||
810 | void QtRec::stop() { | 815 | void QtRec::stop() { |
811 | // owarn << "STOP" << oendl; | 816 | // owarn << "STOP" << oendl; |
812 | setRecordButton(false); | 817 | setRecordButton(false); |
813 | 818 | ||
814 | if( !recording) | 819 | if( !recording) { |
820 | emit stopPlaying(); | ||
815 | endPlaying(); | 821 | endPlaying(); |
816 | else | 822 | } else { |
823 | emit stopRecording(); | ||
817 | endRecording(); | 824 | endRecording(); |
825 | } | ||
818 | timeSlider->setValue(0); | 826 | timeSlider->setValue(0); |
819 | } | 827 | } |
820 | 828 | ||
821 | void QtRec::doPlayBtn() { | 829 | void QtRec::doPlayBtn() { |
822 | 830 | ||
823 | if(!stopped) { | 831 | if(!stopped) { |
824 | // playLabel2->setText(tr("Play")); | 832 | // playLabel2->setText(tr("Play")); |
825 | stop(); | 833 | stop(); |
826 | } else { | 834 | } else { |
827 | if(ListView1->currentItem() == 0) return; | 835 | if(ListView1->currentItem() == 0) return; |
828 | // playLabel2->setText(tr("Stop")); | 836 | // playLabel2->setText(tr("Stop")); |
829 | currentFile = ListView1->currentItem()->text(0); | 837 | currentFile = ListView1->currentItem()->text(0); |
830 | start(); | 838 | start(); |
831 | } | 839 | } |
832 | } | 840 | } |
833 | 841 | ||
834 | void QtRec::start() { //play | 842 | void QtRec::start() { //play |
835 | if( stopped) { | 843 | if( stopped) { |
836 | QPixmap image3( ( const char** ) image3_data ); | 844 | QPixmap image3( ( const char** ) image3_data ); |
837 | Stop_PushButton->setPixmap( image3 ); | 845 | Stop_PushButton->setPixmap( image3 ); |
838 | Stop_PushButton->setDown( true); | 846 | Stop_PushButton->setDown( true); |
839 | stopped = false; | 847 | stopped = false; |
840 | paused = false; | 848 | paused = false; |
841 | secCount = 1; | 849 | secCount = 1; |
842 | 850 | ||
843 | if( openPlayFile()) | 851 | if( openPlayFile()) |
844 | if( setupAudio( false)) //recording is false | 852 | if( setupAudio( false)) //recording is false |
845 | doPlay(); | 853 | doPlay(); |
846 | } | 854 | } |
847 | } | 855 | } |
848 | 856 | ||
849 | bool QtRec::rec() { //record | 857 | bool QtRec::rec() { //record |
850 | QString timeString; | 858 | QString timeString; |
851 | timeString.sprintf("%.0f", 0.0); | 859 | timeString.sprintf("%.0f", 0.0); |
852 | // timeLabel->setText( timeString+ " seconds"); | 860 | // timeLabel->setText( timeString+ " seconds"); |
853 | if(!stopped) { | 861 | if(!stopped) { |
854 | monitoring = true; | 862 | monitoring = true; |
855 | return false; | 863 | return false; |
856 | } else { | 864 | } else { |
857 | secCount = 1; | 865 | secCount = 1; |
858 | // playLabel2->setText(tr("Stop")); | 866 | // playLabel2->setText(tr("Stop")); |
859 | monitoring = false; | 867 | monitoring = false; |
860 | setRecordButton( true); | 868 | setRecordButton( true); |
861 | 869 | ||
862 | if( setupAudio( true)) | 870 | if( setupAudio( true)) |
863 | if(setUpFile()) { | 871 | if(setUpFile()) { |
864 | int fileSize = 0; | 872 | int fileSize = 0; |
865 | Config cfg("OpieRec"); | 873 | Config cfg("OpieRec"); |
866 | cfg.setGroup("Settings"); | 874 | cfg.setGroup("Settings"); |
867 | // odebug << "<<<<<<<Device bits " << soundDevice->getDeviceBits() | ||
868 | // << ", device rate " << soundDevice->getDeviceRate() | ||
869 | // << ", device channels " << soundDevice->getDeviceChannels() << oendl; | ||
870 | |||
871 | //filePara.sampleRate = cfg.readNumEntry("samplerate", 22050); | ||
872 | // odebug << "sample rate is " << filePara.sampleRate << "" << oendl; | ||
873 | filePara.SecondsToRecord = getCurrentSizeLimit(); | 875 | filePara.SecondsToRecord = getCurrentSizeLimit(); |
874 | |||
875 | // odebug << "size limit " << filePara.SecondsToRecord << " sec" << oendl; | ||
876 | int diskSize = checkDiskSpace( (const QString &) wavFile->trackName()); | 876 | int diskSize = checkDiskSpace( (const QString &) wavFile->trackName()); |
877 | 877 | ||
878 | if( filePara.SecondsToRecord == 0) { | 878 | if( filePara.SecondsToRecord == 0) { |
879 | fileSize = diskSize; | 879 | fileSize = diskSize; |
880 | } else if( filePara.format == WAVE_FORMAT_PCM) { | 880 | } else if( filePara.format == WAVE_FORMAT_PCM) { |
881 | // odebug << "WAVE_FORMAT_PCM" << oendl; | 881 | // odebug << "WAVE_FORMAT_PCM" << oendl; |
882 | fileSize = (filePara.SecondsToRecord ) * filePara.channels | 882 | fileSize = (filePara.SecondsToRecord ) * filePara.channels |
883 | * filePara.sampleRate * ( filePara.resolution / 8) + 1000; | 883 | * filePara.sampleRate * ( filePara.resolution / 8) + 1000; |
884 | } else { | 884 | } else { |
885 | // odebug << "WAVE_FORMAT_DVI_ADPCM" << oendl; | 885 | // odebug << "WAVE_FORMAT_DVI_ADPCM" << oendl; |
886 | fileSize = ((filePara.SecondsToRecord) * filePara.channels | 886 | fileSize = ((filePara.SecondsToRecord) * filePara.channels |
887 | * filePara.sampleRate * ( filePara.resolution / 8) ) / 4 + 250; | 887 | * filePara.sampleRate * ( filePara.resolution / 8) ) / 4 + 250; |
888 | } | 888 | } |
889 | 889 | ||
890 | filePara.samplesToRecord = fileSize; | 890 | filePara.samplesToRecord = fileSize; |
891 | odebug << "filesize should be " << filePara.samplesToRecord | 891 | odebug << "filesize should be " << filePara.samplesToRecord |
892 | << ", bits " << filePara.resolution << ", rate " << filePara.sampleRate; | 892 | << ", bits " << filePara.resolution << ", rate " << filePara.sampleRate; |
893 | if( paused) { | 893 | if( paused) { |
894 | paused = false; | 894 | paused = false; |
895 | } | 895 | } |
896 | // else { | 896 | // else { |
897 | odebug << "Setting timeslider " << filePara.samplesToRecord << "" << oendl; | 897 | odebug << "Setting timeslider " << filePara.samplesToRecord << "" << oendl; |
898 | // if(fileSize != 0) | 898 | // if(fileSize != 0) |
899 | timeSlider->setRange(0, filePara.samplesToRecord); | 899 | timeSlider->setRange(0, filePara.samplesToRecord); |
900 | // } | 900 | // } |
901 | 901 | ||
902 | if( diskSize < fileSize/1024) { | 902 | if( diskSize < fileSize/1024) { |
903 | QMessageBox::warning(this, | 903 | QMessageBox::warning(this, |
904 | tr("Low Disk Space"), | 904 | tr("Low Disk Space"), |
905 | tr("You are running low of\nrecording space\n" | 905 | tr("You are running low of\nrecording space\n" |
906 | "or a card isn't being recognized")); | 906 | "or a card isn't being recognized")); |
907 | stopped = true; //we need to be stopped | 907 | stopped = true; //we need to be stopped |
908 | stop(); | 908 | stop(); |
909 | } else { | 909 | } else { |
910 | QString msg; | 910 | QString msg; |
911 | msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); | 911 | msg.sprintf("%d, %d, %d", filePara.sampleRate, filePara.channels, filePara.resolution); |
912 | #ifdef DEV_VERSION | 912 | #ifdef DEV_VERSION |
913 | setCaption( msg); | 913 | setCaption( msg); |
914 | #endif | 914 | #endif |
915 | filePara.fileName=currentFile.latin1(); | 915 | filePara.fileName=currentFile.latin1(); |
916 | odebug << "Start recording" << oendl; | 916 | odebug << "Start recording" << oendl; |
917 | stopped = false; | 917 | stopped = false; |
918 | 918 | ||
919 | #ifdef THREADED | 919 | #ifdef THREADED |
920 | odebug << "Start recording thread" << oendl; | 920 | odebug << "Start recording thread" << oendl; |
921 | pthread_t thread1; | 921 | pthread_t thread1; |
922 | pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/); | 922 | pthread_create( &thread1, NULL, (void * (*)(void *))quickRec, NULL/* &*/); |
923 | #endif | 923 | #endif |
924 | toBeginningButton->setEnabled( false); | 924 | toBeginningButton->setEnabled( false); |
925 | toEndButton->setEnabled( false); | 925 | toEndButton->setEnabled( false); |
926 | 926 | ||
927 | startTimer(1000); | 927 | startTimer(1000); |
928 | #ifndef THREADED | 928 | #ifndef THREADED |
929 | quickRec(); | 929 | quickRec(); |
930 | #endif | 930 | #endif |
931 | } | 931 | } |
932 | } //end setUpFile | 932 | } //end setUpFile |
933 | } //end setupAudio | 933 | } //end setupAudio |
934 | return true; | 934 | return true; |
935 | } | 935 | } |
936 | /* | 936 | /* |
937 | This happens when a tab is selected*/ | 937 | This happens when a tab is selected*/ |
938 | void QtRec::thisTab(QWidget* widg) { | 938 | void QtRec::thisTab(QWidget* widg) { |
939 | if(widg != NULL) { | 939 | if(widg != NULL) { |
940 | int index = TabWidget->currentPageIndex(); | 940 | int index = TabWidget->currentPageIndex(); |
941 | 941 | ||
942 | if(index == 0) { //file page | 942 | if(index == 0) { //file page |
943 | } | 943 | } |
944 | 944 | ||
945 | if(index == 1) { //control page | 945 | if(index == 1) { //control page |
946 | fillDirectoryCombo(); | 946 | fillDirectoryCombo(); |
947 | // soundDevice->getOutVol(); | 947 | // soundDevice->getOutVol(); |
948 | // soundDevice->getInVol(); | 948 | // soundDevice->getInVol(); |
949 | } | 949 | } |
950 | 950 | ||
951 | if( index==2) { //help page | 951 | if( index==2) { //help page |
952 | } | 952 | } |
953 | 953 | ||
954 | qApp->processEvents(); | 954 | qApp->processEvents(); |
955 | update(); | 955 | update(); |
956 | } | 956 | } |
957 | } | 957 | } |
958 | 958 | ||
959 | void QtRec::getOutVol( ) { | 959 | void QtRec::getOutVol( ) { |
960 | filePara.outVol = soundDevice->getOutVolume(); | 960 | filePara.outVol = soundDevice->getOutVolume(); |
961 | // odebug << "out vol " << filePara.outVol << "" << oendl; | 961 | // odebug << "out vol " << filePara.outVol << "" << oendl; |
962 | OutputSlider->setValue( -filePara.outVol); | 962 | OutputSlider->setValue( -filePara.outVol); |
963 | } | 963 | } |
964 | 964 | ||
965 | void QtRec::getInVol() { | 965 | void QtRec::getInVol() { |
966 | filePara.inVol = soundDevice->getInVolume(); | 966 | filePara.inVol = soundDevice->getInVolume(); |
967 | // odebug << "in vol " << filePara.inVol << "" << oendl; | 967 | // odebug << "in vol " << filePara.inVol << "" << oendl; |
968 | InputSlider->setValue( -filePara.inVol); | 968 | InputSlider->setValue( -filePara.inVol); |
969 | } | 969 | } |
970 | 970 | ||
971 | void QtRec::changedOutVolume() { | 971 | void QtRec::changedOutVolume() { |
972 | soundDevice->changedOutVolume( -OutputSlider->value()); | 972 | soundDevice->changedOutVolume( -OutputSlider->value()); |
973 | } | 973 | } |
974 | 974 | ||
975 | void QtRec::changedInVolume( ) { | 975 | void QtRec::changedInVolume( ) { |
976 | soundDevice->changedInVolume( -InputSlider->value()); | 976 | soundDevice->changedInVolume( -InputSlider->value()); |
977 | } | 977 | } |
978 | 978 | ||
979 | 979 | ||
980 | bool QtRec::setupAudio( bool b) { | 980 | bool QtRec::setupAudio( bool b) { |
981 | bool ok; | 981 | bool ok; |
982 | int sampleformat, stereo, flags; | 982 | int sampleformat, stereo, flags; |
983 | QString dspString, mixerString; | 983 | QString dspString, mixerString; |
984 | 984 | ||
985 | filePara.resolution = bitRateComboBox->currentText().toInt( &ok,10); //16 | 985 | filePara.resolution = bitRateComboBox->currentText().toInt( &ok,10); //16 |
986 | 986 | ||
987 | if( !b) { | 987 | if( !b) { |
988 | // we want to play | 988 | // we want to play |
989 | #ifdef PDAUDIO //ALSA | 989 | #ifdef PDAUDIO //ALSA |
990 | if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) { | 990 | if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) { |
991 | sampleformat = SND_PCM_FORMAT_S16; | 991 | sampleformat = SND_PCM_FORMAT_S16; |
992 | filePara.resolution = 16; | 992 | filePara.resolution = 16; |
993 | } else if( filePara.resolution == 24 || compressionCheckBox->isChecked() ) { | 993 | } else if( filePara.resolution == 24 || compressionCheckBox->isChecked() ) { |
994 | sampleformat = SND_PCM_FORMAT_S24; | 994 | sampleformat = SND_PCM_FORMAT_S24; |
995 | filePara.resolution = 24; | 995 | filePara.resolution = 24; |
996 | } else if( filePara.resolution == 32 || compressionCheckBox->isChecked() ) { | 996 | } else if( filePara.resolution == 32 || compressionCheckBox->isChecked() ) { |
997 | sampleformat = SND_PCM_FORMAT_S32; | 997 | sampleformat = SND_PCM_FORMAT_S32; |
998 | filePara.resolution = 32; | 998 | filePara.resolution = 32; |
999 | } else { | 999 | } else { |
1000 | sampleformat = SND_PCM_FORMAT_U8; | 1000 | sampleformat = SND_PCM_FORMAT_U8; |
1001 | filePara.resolution = 8; | 1001 | filePara.resolution = 8; |
1002 | } | 1002 | } |
1003 | #else | 1003 | #else |
1004 | // we want to play | 1004 | // we want to play |
1005 | if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) { | 1005 | if( filePara.resolution == 16 || compressionCheckBox->isChecked() ) { |
1006 | sampleformat = AFMT_S16_LE; | 1006 | sampleformat = AFMT_S16_LE; |
1007 | filePara.resolution = 16; | 1007 | filePara.resolution = 16; |
1008 | } else { | 1008 | } else { |
1009 | sampleformat = AFMT_U8; | 1009 | sampleformat = AFMT_U8; |
1010 | filePara.resolution = 8; | 1010 | filePara.resolution = 8; |
1011 | } | 1011 | } |
1012 | #endif | 1012 | #endif |
1013 | 1013 | ||
1014 | stereo = filePara.channels; | 1014 | stereo = filePara.channels; |
1015 | flags = O_WRONLY; | 1015 | flags = O_WRONLY; |
1016 | recording = false; | 1016 | recording = false; |
1017 | } else { // we want to record | 1017 | } else { // we want to record |
1018 | 1018 | ||
1019 | #ifdef PDAUDIO //ALSA | 1019 | #ifdef PDAUDIO //ALSA |
1020 | if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16") | 1020 | if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16") |
1021 | sampleformat = SND_PCM_FORMAT_S16; | 1021 | sampleformat = SND_PCM_FORMAT_S16; |
1022 | else if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "24") | 1022 | else if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "24") |
1023 | sampleformat = SND_PCM_FORMAT_S24; | 1023 | sampleformat = SND_PCM_FORMAT_S24; |
1024 | else if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "32") | 1024 | else if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "32") |
1025 | sampleformat = SND_PCM_FORMAT_S32; | 1025 | sampleformat = SND_PCM_FORMAT_S32; |
1026 | else | 1026 | else |
1027 | sampleformat = SND_PCM_FORMAT_U8; | 1027 | sampleformat = SND_PCM_FORMAT_U8; |
1028 | 1028 | ||
1029 | #else | 1029 | #else |
1030 | if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16") | 1030 | if( !bitRateComboBox->isEnabled() || bitRateComboBox->currentText() == "16") |
1031 | sampleformat = AFMT_S16_LE; | 1031 | sampleformat = AFMT_S16_LE; |
1032 | else | 1032 | else |
1033 | sampleformat = AFMT_U8; | 1033 | sampleformat = AFMT_U8; |
1034 | 1034 | ||
1035 | if( !compressionCheckBox->isChecked()) { | 1035 | if( !compressionCheckBox->isChecked()) { |
1036 | filePara.format = WAVE_FORMAT_PCM; | 1036 | filePara.format = WAVE_FORMAT_PCM; |
1037 | // odebug << "WAVE_FORMAT_PCM" << oendl; | 1037 | // odebug << "WAVE_FORMAT_PCM" << oendl; |
1038 | } else { | 1038 | } else { |
1039 | filePara.format = WAVE_FORMAT_DVI_ADPCM; | 1039 | filePara.format = WAVE_FORMAT_DVI_ADPCM; |
1040 | sampleformat = AFMT_S16_LE; | 1040 | sampleformat = AFMT_S16_LE; |
1041 | // odebug << "WAVE_FORMAT_DVI_ADPCM" << oendl; | 1041 | // odebug << "WAVE_FORMAT_DVI_ADPCM" << oendl; |
1042 | } | 1042 | } |
1043 | #endif | 1043 | #endif |
1044 | 1044 | ||
1045 | stereo = filePara.channels; | 1045 | stereo = filePara.channels; |
1046 | // filePara.sampleRate = sampleRateComboBox->currentText().toInt( &ok,10);//44100; | 1046 | // filePara.sampleRate = sampleRateComboBox->currentText().toInt( &ok,10);//44100; |
1047 | flags= O_RDWR; | 1047 | flags= O_RDWR; |
1048 | // flags= O_RDONLY; | 1048 | // flags= O_RDONLY; |
1049 | recording = true; | 1049 | recording = true; |
1050 | } | 1050 | } |
1051 | 1051 | ||
1052 | // if(soundDevice) delete soundDevice; | ||
1053 | owarn << "<<<<<<<<<<<<<<<<<<<open dsp " << filePara.sampleRate << " " << filePara.channels << " " << sampleformat << "" << oendl; | 1052 | owarn << "<<<<<<<<<<<<<<<<<<<open dsp " << filePara.sampleRate << " " << filePara.channels << " " << sampleformat << "" << oendl; |
1054 | // owarn << "change waveform settings" << oendl; | 1053 | // owarn << "change waveform settings" << oendl; |
1055 | waveform->changeSettings( filePara.sampleRate, filePara.channels ); | 1054 | waveform->changeSettings( filePara.sampleRate, filePara.channels ); |
1056 | 1055 | ||
1057 | soundDevice = new Device( this, b); //open rec | 1056 | soundDevice = new Device( this, b); //open rec |
1058 | // soundDevice->openDsp(); | 1057 | // soundDevice->openDsp(); |
1059 | soundDevice->reset(); | 1058 | soundDevice->reset(); |
1060 | 1059 | ||
1061 | odebug << "device has been made " << soundDevice->sd << "" << oendl; | 1060 | odebug << "device has been made " << soundDevice->sd << "" << oendl; |
1062 | 1061 | ||
1063 | ////////////////// <<<<<<<<<<<<>>>>>>>>>>>> | 1062 | ////////////////// <<<<<<<<<<<<>>>>>>>>>>>> |
1064 | soundDevice->setDeviceFormat( sampleformat); | 1063 | soundDevice->setDeviceFormat( sampleformat); |
1065 | soundDevice->setDeviceChannels( filePara.channels); | 1064 | soundDevice->setDeviceChannels( filePara.channels); |
1066 | soundDevice->setDeviceRate( filePara.sampleRate); | 1065 | soundDevice->setDeviceRate( filePara.sampleRate); |
1067 | soundDevice->getDeviceFragSize(); | 1066 | soundDevice->getDeviceFragSize(); |
1068 | #ifdef QT_QWS_EBX | 1067 | #ifdef QT_QWS_EBX |
1069 | int frag = FRAGSIZE; | 1068 | int frag = FRAGSIZE; |
1070 | soundDevice->setFragSize( frag); | 1069 | soundDevice->setFragSize( frag); |
1071 | soundDevice->getDeviceFragSize(); | 1070 | soundDevice->getDeviceFragSize(); |
1072 | #endif | 1071 | #endif |
1073 | ///////////////// | 1072 | ///////////////// |
1074 | filePara.sd = soundDevice->sd; | 1073 | filePara.sd = soundDevice->sd; |
1075 | 1074 | ||
1076 | if ( filePara.sd == -1) { | 1075 | if ( filePara.sd == -1) { |
1077 | 1076 | ||
1078 | monitoring = false; | 1077 | monitoring = false; |
1079 | stopped = true; | 1078 | stopped = true; |
1080 | update(); | 1079 | update(); |
1081 | setCaption( tr( "OpieRecord " )+ QString::number(VERSION) ); | 1080 | setCaption( tr( "OpieRecord " )+ QString::number(VERSION) ); |
1082 | return false; | 1081 | return false; |
1083 | } | 1082 | } |
1084 | if(autoMute) | 1083 | if(autoMute) |
1085 | doMute(false); | 1084 | doMute(false); |
1086 | 1085 | ||
1087 | return true; | 1086 | return true; |
1088 | } | 1087 | } |
1089 | 1088 | ||
1090 | 1089 | ||
1091 | bool QtRec::setUpFile() { //setup file for recording | 1090 | bool QtRec::setUpFile() { //setup file for recording |
1092 | // odebug << "Setting up wavfile" << oendl; | ||
1093 | // if(wavFile) delete wavFile; | ||
1094 | wavFile = new WavFile( this, (const QString &)"", | 1091 | wavFile = new WavFile( this, (const QString &)"", |
1095 | true, | 1092 | true, |
1096 | filePara.sampleRate, | 1093 | filePara.sampleRate, |
1097 | filePara.channels, | 1094 | filePara.channels, |
1098 | filePara.resolution, | 1095 | filePara.resolution, |
1099 | filePara.format); | 1096 | filePara.format); |
1100 | 1097 | ||
1101 | filePara.fd = wavFile->wavHandle(); | 1098 | filePara.fd = wavFile->wavHandle(); |
1102 | if(filePara.fd == -1) { | 1099 | if(filePara.fd == -1) { |
1103 | return false; | 1100 | return false; |
1104 | } else { | 1101 | } else { |
1105 | // filePara.channels=1; | ||
1106 | } | 1102 | } |
1107 | return true; | 1103 | return true; |
1108 | } | 1104 | } |
1109 | 1105 | ||
1110 | /// <<<<<<<<<<<<<<<< PLAY >>>>>>>>>>>>>>>>>>> | 1106 | /// <<<<<<<<<<<<<<<< PLAY >>>>>>>>>>>>>>>>>>> |
1111 | bool QtRec::doPlay() { | 1107 | bool QtRec::doPlay() { |
1112 | 1108 | ||
1113 | if( !paused) { | 1109 | if( !paused) { |
1114 | total = 0; | 1110 | total = 0; |
1115 | filePara.numberOfRecordedSeconds = 0; | 1111 | filePara.numberOfRecordedSeconds = 0; |
1116 | } else { | 1112 | } else { |
1117 | paused = false; | 1113 | paused = false; |
1118 | secCount = (int)filePara.numberOfRecordedSeconds; | 1114 | secCount = (int)filePara.numberOfRecordedSeconds; |
1119 | } | 1115 | } |
1120 | playing = true; | 1116 | playing = true; |
1121 | stopped = false; | 1117 | stopped = false; |
1122 | recording = false; | 1118 | recording = false; |
1123 | 1119 | ||
1124 | QString num; | 1120 | QString num; |
1125 | odebug << "Play number of samples " << filePara.numberSamples << "" << oendl; | 1121 | odebug << "Play number of samples " << filePara.numberSamples << "" << oendl; |
1126 | 1122 | ||
1127 | // timeSlider->setRange( 0, filePara.numberSamples); | 1123 | // timeSlider->setRange( 0, filePara.numberSamples); |
1128 | 1124 | ||
1129 | timeString.sprintf("%f", filePara.numberOfRecordedSeconds); | 1125 | timeString.sprintf("%f", filePara.numberOfRecordedSeconds); |
1130 | // timeLabel->setText( timeString+ tr(" seconds")); | 1126 | // timeLabel->setText( timeString+ tr(" seconds")); |
1131 | 1127 | ||
1132 | QString msg; | 1128 | QString msg; |
1133 | msg.sprintf("%d, %d, %d", | 1129 | msg.sprintf("%d, %d, %d", |
1134 | filePara.sampleRate, | 1130 | filePara.sampleRate, |
1135 | filePara.channels, | 1131 | filePara.channels, |
1136 | filePara.resolution); | 1132 | filePara.resolution); |
1137 | #ifdef DEV_VERSION | 1133 | #ifdef DEV_VERSION |
1138 | setCaption( msg); | 1134 | setCaption( msg); |
1139 | #endif | 1135 | #endif |
1140 | 1136 | ||
1141 | startTimer( 1000); | 1137 | startTimer( 1000); |
1142 | #ifdef THREADED | 1138 | #ifdef THREADED |
1143 | pthread_t thread2; | 1139 | pthread_t thread2; |
1144 | pthread_create( &thread2, NULL, (void * (*)(void *))playIt, NULL/* &*/); | 1140 | pthread_create( &thread2, NULL, (void * (*)(void *))playIt, NULL/* &*/); |
1145 | #endif | 1141 | #endif |
1146 | 1142 | ||
1147 | toBeginningButton->setEnabled( false); | 1143 | toBeginningButton->setEnabled( false); |
1148 | toEndButton->setEnabled( false); | 1144 | toEndButton->setEnabled( false); |
1149 | #ifndef THREADED | 1145 | #ifndef THREADED |
1150 | playIt(); | 1146 | playIt(); |
1151 | #endif | 1147 | #endif |
1152 | return true; | 1148 | return true; |
1153 | } | 1149 | } |
1154 | 1150 | ||
1155 | 1151 | ||
1156 | void QtRec::changebitrateCombo(int i) { | 1152 | void QtRec::changebitrateCombo(int i) { |
1157 | Config cfg("OpieRec"); | 1153 | Config cfg("OpieRec"); |
1158 | cfg.setGroup("Settings"); | 1154 | cfg.setGroup("Settings"); |
1159 | int bits = 0; | 1155 | int bits = 0; |
1160 | if( i == 1) { bits = 16; } | 1156 | if( i == 1) { bits = 16; } |
1161 | else if( i == 2) { bits = 24; } | 1157 | else if( i == 2) { bits = 24; } |
1162 | else if( i == 3) { bits = 32; } | 1158 | else if( i == 3) { bits = 32; } |
1163 | else { bits=8; } | 1159 | else { bits=8; } |
1164 | cfg.writeEntry("bitrate", bits); | 1160 | cfg.writeEntry("bitrate", bits); |
1165 | filePara.resolution = bits; | 1161 | filePara.resolution = bits; |
1166 | cfg.write(); | 1162 | cfg.write(); |
1167 | } | 1163 | } |
1168 | 1164 | ||
1169 | void QtRec::changesamplerateCombo(int i) { | 1165 | void QtRec::changesamplerateCombo(int i) { |
1170 | Config cfg("OpieRec"); | 1166 | Config cfg("OpieRec"); |
1171 | cfg.setGroup("Settings"); | 1167 | cfg.setGroup("Settings"); |
1172 | int rate=0; | 1168 | int rate=0; |
1173 | bool ok; | 1169 | bool ok; |
1174 | rate = sampleRateComboBox->text(i).toInt(&ok, 10); | 1170 | rate = sampleRateComboBox->text(i).toInt(&ok, 10); |
1175 | cfg.writeEntry( "samplerate",rate); | 1171 | cfg.writeEntry( "samplerate",rate); |
1176 | filePara.sampleRate=rate; | 1172 | filePara.sampleRate=rate; |
1177 | odebug << "Change sample rate " << rate << "" << oendl; | 1173 | odebug << "Change sample rate " << rate << "" << oendl; |
1178 | cfg.write(); | 1174 | cfg.write(); |
1179 | } | 1175 | } |
1180 | 1176 | ||
1181 | 1177 | ||
1182 | void QtRec::changeDirCombo(int index) { | 1178 | void QtRec::changeDirCombo(int index) { |
1183 | Config cfg("OpieRec"); | 1179 | Config cfg("OpieRec"); |
1184 | cfg.setGroup("Settings"); | 1180 | cfg.setGroup("Settings"); |
1185 | QString sName = directoryComboBox->text(index); | 1181 | QString sName = directoryComboBox->text(index); |
1186 | 1182 | ||
1187 | StorageInfo storageInfo; | 1183 | StorageInfo storageInfo; |
1188 | const QList<FileSystem> &fs = storageInfo.fileSystems(); | 1184 | const QList<FileSystem> &fs = storageInfo.fileSystems(); |
1189 | QListIterator<FileSystem> it ( fs ); | 1185 | QListIterator<FileSystem> it ( fs ); |
1190 | QString storage; | 1186 | QString storage; |
1191 | for( ; it.current(); ++it ){ | 1187 | for( ; it.current(); ++it ){ |
1192 | if( sName == (*it)->name()+" "+ (*it)->path() || | 1188 | if( sName == (*it)->name()+" "+ (*it)->path() || |
1193 | (*it)->name() == sName ) { | 1189 | (*it)->name() == sName ) { |
1194 | const QString path = (*it)->path(); | 1190 | const QString path = (*it)->path(); |
1195 | recDir = path; | 1191 | recDir = path; |
1196 | cfg.writeEntry("directory", recDir); | 1192 | cfg.writeEntry("directory", recDir); |
1197 | odebug << "new rec dir "+recDir << oendl; | 1193 | odebug << "new rec dir "+recDir << oendl; |
1198 | } | 1194 | } |
1199 | } | 1195 | } |
1200 | cfg.write(); | 1196 | cfg.write(); |
1201 | } | 1197 | } |
1202 | 1198 | ||
1203 | 1199 | ||
1204 | void QtRec::changeSizeLimitCombo(int) { | 1200 | void QtRec::changeSizeLimitCombo(int) { |
1205 | Config cfg("OpieRec"); | 1201 | Config cfg("OpieRec"); |
1206 | cfg.setGroup("Settings"); | 1202 | cfg.setGroup("Settings"); |
1207 | cfg.writeEntry("sizeLimit", getCurrentSizeLimit() ); | 1203 | cfg.writeEntry("sizeLimit", getCurrentSizeLimit() ); |
1208 | cfg.write(); | 1204 | cfg.write(); |
1209 | } | 1205 | } |
1210 | 1206 | ||
1211 | void QtRec::newSound() { | 1207 | void QtRec::newSound() { |
1212 | if( !rec()) { | 1208 | if( !rec()) { |
1213 | endRecording(); | 1209 | endRecording(); |
1214 | deleteSound(); | 1210 | deleteSound(); |
1215 | } | 1211 | } |
1216 | } | 1212 | } |
1217 | 1213 | ||
1218 | void QtRec::itClick(QListViewItem *item) { | 1214 | void QtRec::itClick(QListViewItem *item) { |
1219 | currentFile = item->text(0); | 1215 | currentFile = item->text(0); |
1220 | setCaption("OpieRecord "+currentFile); | 1216 | setCaption("OpieRecord "+currentFile); |
1221 | } | 1217 | } |
1222 | 1218 | ||
1223 | void QtRec::deleteSound() { | 1219 | void QtRec::deleteSound() { |
1224 | Config cfg("OpieRec"); | 1220 | Config cfg("OpieRec"); |
1225 | cfg.setGroup("Sounds"); | 1221 | cfg.setGroup("Sounds"); |
1226 | if( ListView1->currentItem() == NULL) | 1222 | if( ListView1->currentItem() == NULL) |
1227 | return; | 1223 | return; |
1228 | // #ifndef DEV_VERSION | ||
1229 | // switch ( QMessageBox::warning(this,tr("Delete"), | ||
1230 | // tr("Do you really want to <font size=+2><B>DELETE</B></font>\nthe selected file?"), | ||
1231 | // tr("Yes"),tr("No"),0,1,1) ) { | ||
1232 | // case 0: | ||
1233 | // #endif | ||
1234 | // { | ||
1235 | QString file = ListView1->currentItem()->text(0); | 1224 | QString file = ListView1->currentItem()->text(0); |
1236 | QString fileName; | 1225 | QString fileName; |
1237 | fileName = cfg.readEntry( file, ""); | 1226 | fileName = cfg.readEntry( file, ""); |
1238 | QFile f( fileName); | 1227 | QFile f( fileName); |
1239 | if( f.exists()) | 1228 | if( f.exists()) |
1240 | if( !f.remove()) | 1229 | if( !f.remove()) |
1241 | QMessageBox::message( tr("Error"), tr("Could not remove file.")); | 1230 | QMessageBox::message( tr("Error"), tr("Could not remove file.")); |
1242 | 1231 | ||
1243 | int nFiles = cfg.readNumEntry( "NumberofFiles",0); | 1232 | int nFiles = cfg.readNumEntry( "NumberofFiles",0); |
1244 | bool found = false; | 1233 | bool found = false; |
1245 | for(int i=0;i<nFiles+1;i++) { | 1234 | for(int i=0;i<nFiles+1;i++) { |
1246 | 1235 | ||
1247 | if( cfg.readEntry( QString::number(i),"").find( file,0,true) != -1) { | 1236 | if( cfg.readEntry( QString::number(i),"").find( file,0,true) != -1) { |
1248 | found = true; | 1237 | found = true; |
1249 | cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),"")); | 1238 | cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),"")); |
1250 | } | 1239 | } |
1251 | if(found) | 1240 | if(found) |
1252 | cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),"")); | 1241 | cfg.writeEntry( QString::number(i), cfg.readEntry( QString::number(i+1),"")); |
1253 | } | 1242 | } |
1254 | 1243 | ||
1255 | cfg.removeEntry( cfg.readEntry( file)); | 1244 | cfg.removeEntry( cfg.readEntry( file)); |
1256 | cfg.removeEntry( file); | 1245 | cfg.removeEntry( file); |
1257 | cfg.writeEntry( "NumberofFiles", nFiles-1); | 1246 | cfg.writeEntry( "NumberofFiles", nFiles-1); |
1258 | cfg.write(); | 1247 | cfg.write(); |
1259 | 1248 | ||
1260 | ListView1->takeItem( ListView1->currentItem() ); | 1249 | ListView1->takeItem( ListView1->currentItem() ); |
1261 | delete ListView1->currentItem(); | 1250 | delete ListView1->currentItem(); |
1262 | 1251 | ||
1263 | ListView1->clear(); | 1252 | ListView1->clear(); |
1264 | ListView1->setSelected( ListView1->firstChild(), true); | 1253 | ListView1->setSelected( ListView1->firstChild(), true); |
1265 | initIconView(); | 1254 | initIconView(); |
1266 | update(); | 1255 | update(); |
1267 | setCaption( tr( "OpieRecord " )); | 1256 | setCaption( tr( "OpieRecord " )); |
1268 | } | 1257 | } |
1269 | 1258 | ||
1270 | void QtRec::keyPressEvent( QKeyEvent *e) { | 1259 | void QtRec::keyPressEvent( QKeyEvent *e) { |
1271 | 1260 | ||
1272 | switch ( e->key() ) { | 1261 | switch ( e->key() ) { |
1273 | // case Key_F1: | 1262 | // case Key_F1: |
1274 | // if(stopped && !recording) | 1263 | // if(stopped && !recording) |
1275 | // newSound(); | 1264 | // newSound(); |
1276 | // else | 1265 | // else |
1277 | // stop(); | 1266 | // stop(); |
1278 | // break; | 1267 | // break; |
1279 | // case Key_F2: { | 1268 | // case Key_F2: { |
1280 | // if( !e->isAutoRepeat()) | 1269 | // if( !e->isAutoRepeat()) |
1281 | // rewindPressed(); | 1270 | // rewindPressed(); |
1282 | // } | 1271 | // } |
1283 | // break; | 1272 | // break; |
1284 | // case Key_F3: { | 1273 | // case Key_F3: { |
1285 | // if( !e->isAutoRepeat()) | 1274 | // if( !e->isAutoRepeat()) |
1286 | // FastforwardPressed(); | 1275 | // FastforwardPressed(); |
1287 | // } | 1276 | // } |
1288 | // break; | 1277 | // break; |
1289 | 1278 | ||
1290 | ////////////////////////////// Zaurus keys | 1279 | ////////////////////////////// Zaurus keys |
1291 | case Key_F9: //activity | 1280 | case Key_F9: //activity |
1292 | break; | 1281 | break; |
1293 | case Key_F10: //contacts | 1282 | case Key_F10: //contacts |
1294 | break; | 1283 | break; |
1295 | case Key_F11: //menu | 1284 | case Key_F11: //menu |
1296 | break; | 1285 | break; |
1297 | case Key_F12: //home | 1286 | case Key_F12: //home |
1298 | break; | 1287 | break; |
1299 | case Key_F13: //mail | 1288 | case Key_F13: //mail |
1300 | break; | 1289 | break; |
1301 | case Key_Space: | 1290 | case Key_Space: |
1302 | break; | 1291 | break; |
1303 | case Key_Delete: | 1292 | case Key_Delete: |
1304 | break; | 1293 | break; |
1305 | case Key_Up: | 1294 | case Key_Up: |
1306 | // stop(); | 1295 | // stop(); |
1307 | break; | 1296 | break; |
1308 | case Key_Down: | 1297 | case Key_Down: |
1309 | // newSound(); | 1298 | // newSound(); |
1310 | break; | 1299 | break; |
1311 | case Key_Left: { | 1300 | case Key_Left: { |
1312 | odebug << "rewinding" << oendl; | 1301 | odebug << "rewinding" << oendl; |
1313 | if( !e->isAutoRepeat()) | 1302 | if( !e->isAutoRepeat()) |
1314 | rewindPressed(); | 1303 | rewindPressed(); |
1315 | } | 1304 | } |
1316 | break; | 1305 | break; |
1317 | case Key_Right: { | 1306 | case Key_Right: { |
1318 | if( !e->isAutoRepeat()) | 1307 | if( !e->isAutoRepeat()) |
1319 | FastforwardPressed(); | 1308 | FastforwardPressed(); |
1320 | } | 1309 | } |
1321 | break; | 1310 | break; |
1322 | } | 1311 | } |
1323 | } | 1312 | } |
1324 | 1313 | ||
1325 | void QtRec::keyReleaseEvent( QKeyEvent *e) { | 1314 | void QtRec::keyReleaseEvent( QKeyEvent *e) { |
1326 | switch ( e->key() ) { | 1315 | switch ( e->key() ) { |
1327 | // case Key_F1: | 1316 | // case Key_F1: |
1328 | // if(stopped && !recording) | 1317 | // if(stopped && !recording) |
1329 | // newSound(); | 1318 | // newSound(); |
1330 | // else | 1319 | // else |
1331 | // stop(); | 1320 | // stop(); |
1332 | // break; | 1321 | // break; |
1333 | // case Key_F2: | 1322 | // case Key_F2: |
1334 | // rewindReleased(); | 1323 | // rewindReleased(); |
1335 | // break; | 1324 | // break; |
1336 | // case Key_F3: | 1325 | // case Key_F3: |
1337 | // FastforwardReleased(); | 1326 | // FastforwardReleased(); |
1338 | // break; | 1327 | // break; |
1339 | 1328 | ||
1340 | ////////////////////////////// Zaurus keys | 1329 | ////////////////////////////// Zaurus keys |
1341 | case Key_F9: //activity | 1330 | case Key_F9: //activity |
1342 | break; | 1331 | break; |
1343 | case Key_F10: //contacts | 1332 | case Key_F10: //contacts |
1344 | break; | 1333 | break; |
1345 | case Key_F11: //menu | 1334 | case Key_F11: //menu |
1346 | break; | 1335 | break; |
1347 | case Key_F12: //home | 1336 | case Key_F12: //home |
1348 | if(stopped) | 1337 | if(stopped) |
1349 | doPlayBtn(); | 1338 | doPlayBtn(); |
1350 | else | 1339 | else |
1351 | stop(); | 1340 | stop(); |
1352 | break; | 1341 | break; |
1353 | case Key_F13: //mail | 1342 | case Key_F13: //mail |
1354 | break; | 1343 | break; |
1355 | case Key_Space: | 1344 | case Key_Space: |
1356 | if(stopped && !recording) | 1345 | if(stopped && !recording) |
1357 | newSound(); | 1346 | newSound(); |
1358 | else | 1347 | else |
1359 | stop(); | 1348 | stop(); |
1360 | break; | 1349 | break; |
1361 | case Key_Delete: | 1350 | case Key_Delete: |
1362 | deleteSound(); | 1351 | deleteSound(); |
1363 | break; | 1352 | break; |
1364 | case Key_Up: | 1353 | case Key_Up: |
1365 | // stop(); | 1354 | // stop(); |
1366 | odebug << "Up" << oendl; | 1355 | odebug << "Up" << oendl; |
1367 | break; | 1356 | break; |
1368 | case Key_Down: | 1357 | case Key_Down: |
1369 | // start(); | 1358 | // start(); |
1370 | // odebug << "Down" << oendl; | 1359 | // odebug << "Down" << oendl; |
1371 | // newSound(); | 1360 | // newSound(); |
1372 | break; | 1361 | break; |
1373 | case Key_Left: | 1362 | case Key_Left: |
1374 | odebug << "Left" << oendl; | 1363 | odebug << "Left" << oendl; |
1375 | rewindReleased(); | 1364 | rewindReleased(); |
1376 | break; | 1365 | break; |
1377 | case Key_Right: | 1366 | case Key_Right: |
1378 | odebug << "Right" << oendl; | 1367 | odebug << "Right" << oendl; |
1379 | FastforwardReleased(); | 1368 | FastforwardReleased(); |
1380 | break; | 1369 | break; |
1381 | } | 1370 | } |
1382 | } | 1371 | } |
1383 | 1372 | ||
1384 | void QtRec::endRecording() { | 1373 | void QtRec::endRecording() { |
1385 | 1374 | ||
1386 | monitoring = false; | 1375 | monitoring = false; |
1387 | recording = false; | 1376 | recording = false; |
1388 | stopped = true; | 1377 | stopped = true; |
1389 | waveform->reset(); | 1378 | waveform->reset(); |
1390 | setRecordButton( false); | 1379 | setRecordButton( false); |
1391 | 1380 | ||
1392 | toBeginningButton->setEnabled( true); | 1381 | toBeginningButton->setEnabled( true); |
1393 | toEndButton->setEnabled( true); | 1382 | toEndButton->setEnabled( true); |
1394 | 1383 | ||
1395 | killTimers(); | 1384 | killTimers(); |
1396 | 1385 | ||
1397 | if(autoMute) | 1386 | if(autoMute) |
1398 | doMute( true); | 1387 | doMute( true); |
1399 | 1388 | ||
1400 | soundDevice->closeDevice( true); | 1389 | soundDevice->closeDevice( true); |
1401 | 1390 | ||
1402 | if( wavFile->track.isOpen()) { | 1391 | if( wavFile->track.isOpen()) { |
1403 | wavFile->adjustHeaders( filePara.fd, filePara.numberSamples); | 1392 | wavFile->adjustHeaders( filePara.fd, filePara.numberSamples); |
1404 | // soundDevice->sd=-1; | ||
1405 | filePara.numberSamples = 0; | 1393 | filePara.numberSamples = 0; |
1406 | // filePara.sd=-1; | ||
1407 | wavFile->closeFile(); | 1394 | wavFile->closeFile(); |
1408 | filePara.fd=0; | 1395 | filePara.fd=0; |
1409 | 1396 | ||
1410 | if( wavFile->isTempFile()) { | 1397 | if( wavFile->isTempFile()) { |
1411 | // move tmp file to regular file | 1398 | // move tmp file to regular file |
1412 | QString cmd; | 1399 | QString cmd; |
1413 | cmd.sprintf("mv "+ wavFile->trackName() + " " + wavFile->currentFileName); | 1400 | cmd.sprintf("mv "+ wavFile->trackName() + " " + wavFile->currentFileName); |
1414 | odebug << "moving tmp file to "+currentFileName << oendl; | 1401 | odebug << "moving tmp file to "+currentFileName << oendl; |
1415 | system( cmd.latin1()); | 1402 | system( cmd.latin1()); |
1416 | } | 1403 | } |
1417 | 1404 | ||
1418 | odebug << "Just moved " + wavFile->currentFileName << oendl; | 1405 | odebug << "Just moved " + wavFile->currentFileName << oendl; |
1419 | Config cfg("OpieRec"); | 1406 | Config cfg("OpieRec"); |
1420 | cfg.setGroup("Sounds"); | 1407 | cfg.setGroup("Sounds"); |
1421 | 1408 | ||
1422 | int nFiles = cfg.readNumEntry( "NumberofFiles",0); | 1409 | int nFiles = cfg.readNumEntry( "NumberofFiles",0); |
1423 | 1410 | ||
1424 | currentFile = QFileInfo( wavFile->currentFileName).fileName(); | 1411 | currentFile = QFileInfo( wavFile->currentFileName).fileName(); |
1425 | currentFile = currentFile.left( currentFile.length() - 4); | 1412 | currentFile = currentFile.left( currentFile.length() - 4); |
1426 | 1413 | ||
1427 | cfg.writeEntry( "NumberofFiles", nFiles + 1); | 1414 | cfg.writeEntry( "NumberofFiles", nFiles + 1); |
1428 | cfg.writeEntry( QString::number( nFiles + 1), currentFile); | 1415 | cfg.writeEntry( QString::number( nFiles + 1), currentFile); |
1429 | cfg.writeEntry( currentFile, wavFile->currentFileName); | 1416 | cfg.writeEntry( currentFile, wavFile->currentFileName); |
1430 | 1417 | ||
1431 | QString time; | 1418 | QString time; |
1432 | time.sprintf("%.2f", filePara.numberOfRecordedSeconds); | 1419 | time.sprintf("%.2f", filePara.numberOfRecordedSeconds); |
1433 | cfg.writeEntry( wavFile->currentFileName, time ); | 1420 | cfg.writeEntry( wavFile->currentFileName, time ); |
1434 | odebug << "writing config numberOfRecordedSeconds "+time << oendl; | 1421 | odebug << "writing config numberOfRecordedSeconds "+time << oendl; |
1435 | 1422 | ||
1436 | cfg.write(); | 1423 | cfg.write(); |
1437 | odebug << "finished recording" << oendl; | 1424 | odebug << "finished recording" << oendl; |
1438 | // timeLabel->setText(""); | 1425 | // timeLabel->setText(""); |
1439 | } | 1426 | } |
1440 | 1427 | ||
1441 | // if(soundDevice) delete soundDevice; | 1428 | // if(soundDevice) delete soundDevice; |
1442 | 1429 | ||
1443 | timeSlider->setValue(0); | 1430 | timeSlider->setValue(0); |
1444 | initIconView(); | 1431 | initIconView(); |
1445 | selectItemByName( currentFile); | 1432 | selectItemByName( currentFile); |
1446 | setCaption( tr( "OpieRecord " )); | 1433 | setCaption( tr( "OpieRecord " )); |
1447 | 1434 | ||
1448 | } | 1435 | } |
1449 | 1436 | ||
1450 | void QtRec::endPlaying() { | 1437 | void QtRec::endPlaying() { |
1451 | monitoring = false; | 1438 | monitoring = false; |
1452 | recording = false; | 1439 | recording = false; |
1453 | playing = false; | 1440 | playing = false; |
1454 | stopped = true; | 1441 | stopped = true; |
1455 | waveform->reset(); | 1442 | waveform->reset(); |
1456 | // errorStop(); | 1443 | // errorStop(); |
1457 | odebug << "end playing" << oendl; | 1444 | odebug << "end playing" << oendl; |
1458 | setRecordButton( false); | 1445 | setRecordButton( false); |
1459 | 1446 | ||
1460 | toBeginningButton->setEnabled( true); | 1447 | toBeginningButton->setEnabled( true); |
1461 | toEndButton->setEnabled( true); | 1448 | toEndButton->setEnabled( true); |
1462 | 1449 | ||
1463 | if(autoMute) | 1450 | if(autoMute) |
1464 | doMute( true); | 1451 | doMute( true); |
1465 | 1452 | ||
1466 | soundDevice->closeDevice( false); | 1453 | soundDevice->closeDevice( false); |
1467 | soundDevice->sd = -1; | 1454 | soundDevice->sd = -1; |
1468 | // if(soundDevice) delete soundDevice; | 1455 | // if(soundDevice) delete soundDevice; |
1469 | odebug << "file and sound device closed" << oendl; | 1456 | odebug << "file and sound device closed" << oendl; |
1470 | // timeLabel->setText(""); | 1457 | // timeLabel->setText(""); |
1471 | total = 0; | 1458 | total = 0; |
1472 | filePara.numberSamples = 0; | 1459 | filePara.numberSamples = 0; |
1473 | filePara.sd = -1; | 1460 | filePara.sd = -1; |
1474 | // wavFile->closeFile(); | 1461 | // wavFile->closeFile(); |
1475 | filePara.fd = 0; | 1462 | filePara.fd = 0; |
1476 | // if(wavFile) delete wavFile; //this crashes | 1463 | // if(wavFile) delete wavFile; //this crashes |
1477 | 1464 | ||
1478 | odebug << "track closed" << oendl; | 1465 | odebug << "track closed" << oendl; |
1479 | killTimers(); | 1466 | killTimers(); |
1480 | // owarn << "reset slider" << oendl; | 1467 | // owarn << "reset slider" << oendl; |
1481 | timeSlider->setValue(0); | 1468 | timeSlider->setValue(0); |
1482 | 1469 | ||
1483 | // if(soundDevice) delete soundDevice; | 1470 | // if(soundDevice) delete soundDevice; |
1484 | 1471 | ||
1485 | } | 1472 | } |
1486 | 1473 | ||
1487 | bool QtRec::openPlayFile() { | 1474 | bool QtRec::openPlayFile() { |
1488 | qWarning("opening file"); | 1475 | qWarning("opening file"); |
1489 | qApp->processEvents(); | 1476 | qApp->processEvents(); |
1490 | if( currentFile.isEmpty()) { | 1477 | if( currentFile.isEmpty()) { |
1491 | QMessageBox::message(tr("Opierec"),tr("Please select file to play")); | 1478 | QMessageBox::message(tr("Opierec"),tr("Please select file to play")); |
1492 | endPlaying(); | 1479 | endPlaying(); |
1493 | return false; | 1480 | return false; |
1494 | } | 1481 | } |
1495 | QString currentFileName; | 1482 | QString currentFileName; |
1496 | Config cfg("OpieRec"); | 1483 | Config cfg("OpieRec"); |
1497 | cfg.setGroup("Sounds"); | 1484 | cfg.setGroup("Sounds"); |
1498 | int nFiles = cfg.readNumEntry( "NumberofFiles", 0); | 1485 | int nFiles = cfg.readNumEntry( "NumberofFiles", 0); |
1499 | for(int i=0;i<nFiles+1;i++) { //look for file | 1486 | for(int i=0;i<nFiles+1;i++) { //look for file |
1500 | if( cfg.readEntry( QString::number(i),"").find( currentFile,0,true) != -1) { | 1487 | if( cfg.readEntry( QString::number(i),"").find( currentFile,0,true) != -1) { |
1501 | currentFileName = cfg.readEntry( currentFile, "" ); | 1488 | currentFileName = cfg.readEntry( currentFile, "" ); |
1502 | odebug << "opening for play: " + currentFileName << oendl; | 1489 | odebug << "opening for play: " + currentFileName << oendl; |
diff --git a/noncore/multimedia/opierec/qtrec.h b/noncore/multimedia/opierec/qtrec.h index 642048a..6e81af6 100644 --- a/noncore/multimedia/opierec/qtrec.h +++ b/noncore/multimedia/opierec/qtrec.h | |||
@@ -1,187 +1,196 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** Created: Thu Jan 17 11:19:45 2002 | 2 | ** Created: Thu Jan 17 11:19:45 2002 |
3 | copyright 2002 by L.J. Potter ljp@llornkcor.com | 3 | 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 20040628 | 7 | #define VERSION 20040628 |
8 | 8 | ||
9 | #include <qpe/ir.h> | 9 | #include <qpe/ir.h> |
10 | 10 | ||
11 | #include <qfile.h> | 11 | #include <qfile.h> |
12 | #include <qimage.h> | 12 | #include <qimage.h> |
13 | #include <qlineedit.h> | 13 | #include <qlineedit.h> |
14 | #include <qpixmap.h> | 14 | #include <qpixmap.h> |
15 | #include <qvariant.h> | 15 | #include <qvariant.h> |
16 | #include <qwidget.h> | 16 | #include <qwidget.h> |
17 | #include <stdio.h> | 17 | #include <stdio.h> |
18 | #include <stdlib.h> | 18 | #include <stdlib.h> |
19 | 19 | ||
20 | #include "device.h" | 20 | #include "device.h" |
21 | #include "wavFile.h" | 21 | #include "wavFile.h" |
22 | 22 | ||
23 | class QButtonGroup; | 23 | class QButtonGroup; |
24 | class QCheckBox; | 24 | class QCheckBox; |
25 | class QComboBox; | 25 | class QComboBox; |
26 | class QGridLayout; | 26 | class QGridLayout; |
27 | class QGroupBox; | 27 | class QGroupBox; |
28 | class QHBoxLayout; | 28 | class QHBoxLayout; |
29 | class QIconView; | 29 | class QIconView; |
30 | class QIconViewItem; | 30 | class QIconViewItem; |
31 | class QLabel; | 31 | class QLabel; |
32 | class QLabel; | 32 | class QLabel; |
33 | class QListView; | 33 | class QListView; |
34 | class QListViewItem; | 34 | class QListViewItem; |
35 | class QPushButton; | 35 | class QPushButton; |
36 | class QSlider; | 36 | class QSlider; |
37 | class QTabWidget; | 37 | class QTabWidget; |
38 | class QTimer; | 38 | class QTimer; |
39 | class QVBoxLayout; | 39 | class QVBoxLayout; |
40 | class QLineEdit; | 40 | class QLineEdit; |
41 | 41 | ||
42 | #define MAX_TRACKS 2 | 42 | #define MAX_TRACKS 2 |
43 | //#define BUFSIZE 4096 | 43 | //#define BUFSIZE 4096 |
44 | // #define BUFSIZE 8182 //Z default buffer size | 44 | // #define BUFSIZE 8182 //Z default buffer size |
45 | #define BUFSIZE 1024 | 45 | #define BUFSIZE 1024 |
46 | //#define BUFSIZE 2048 | 46 | //#define BUFSIZE 2048 |
47 | #define FRAGSIZE 0x7fff000A; | 47 | #define FRAGSIZE 0x7fff000A; |
48 | 48 | ||
49 | #define WAVE_FORMAT_DVI_ADPCM (0x0011) | 49 | #define WAVE_FORMAT_DVI_ADPCM (0x0011) |
50 | #define WAVE_FORMAT_PCM (0x0001) | 50 | #define WAVE_FORMAT_PCM (0x0001) |
51 | //AFMT_IMA_ADPCM | 51 | //AFMT_IMA_ADPCM |
52 | 52 | ||
53 | class QtRec : public QWidget | 53 | class QtRec : public QWidget |
54 | { | 54 | { |
55 | Q_OBJECT | 55 | Q_OBJECT |
56 | 56 | ||
57 | public: | 57 | public: |
58 | static QString appName() { return QString::fromLatin1("opierec"); } | 58 | static QString appName() { return QString::fromLatin1("opierec"); } |
59 | QtRec( QWidget* parent=0, const char* name=0, WFlags fl=0 ); | 59 | QtRec( QWidget* parent=0, const char* name=0, WFlags fl=0 ); |
60 | ~QtRec(); | 60 | ~QtRec(); |
61 | QSlider *OutputSlider,*InputSlider; | 61 | QSlider *OutputSlider,*InputSlider; |
62 | 62 | ||
63 | signals: | ||
64 | void stopRecording(); | ||
65 | void startRecording(); | ||
66 | void stopPlaying(); | ||
67 | void startPlaying(); | ||
68 | |||
63 | public slots: | 69 | public slots: |
70 | |||
64 | private: | 71 | private: |
65 | // int fragment; | 72 | // int fragment; |
66 | int fd1; | 73 | int fd1; |
67 | int secCount; | 74 | int secCount; |
68 | QString timeString; | 75 | QString timeString; |
69 | 76 | ||
70 | QLineEdit *renameBox; | 77 | QLineEdit *renameBox; |
71 | QGroupBox* GroupBox1; | 78 | QGroupBox* GroupBox1; |
72 | QString currentFile; | 79 | QString currentFile; |
73 | QString date, currentFileName, tmpFileName; | 80 | QString date, currentFileName, tmpFileName; |
74 | QTimer *t_timer; | 81 | QTimer *t_timer; |
75 | bool needsStereoOut, paused; | 82 | bool needsStereoOut, paused; |
76 | bool useTmpFile, autoMute; | 83 | bool useTmpFile, autoMute; |
77 | 84 | ||
78 | bool eventFilter( QObject * , QEvent * ); | 85 | bool eventFilter( QObject * , QEvent * ); |
79 | void okRename(); | 86 | void okRename(); |
80 | void cancelRename(); | 87 | void cancelRename(); |
81 | QString getStorage(const QString &); | 88 | QString getStorage(const QString &); |
82 | bool rec(); | 89 | bool rec(); |
83 | int getCurrentSizeLimit(); | 90 | int getCurrentSizeLimit(); |
84 | long checkDiskSpace(const QString &); | 91 | long checkDiskSpace(const QString &); |
85 | void doMute(bool); | 92 | void doMute(bool); |
86 | void errorStop(); | 93 | void errorStop(); |
87 | void fillDirectoryCombo(); | 94 | void fillDirectoryCombo(); |
88 | void getInVol(); | 95 | void getInVol(); |
89 | void getOutVol(); | 96 | void getOutVol(); |
90 | void init(); | 97 | void init(); |
91 | void initConfig(); | 98 | void initConfig(); |
92 | void initConnections(); | 99 | void initConnections(); |
93 | void selectItemByName(const QString &); | 100 | void selectItemByName(const QString &); |
94 | void setRecordButton(bool); | 101 | void setRecordButton(bool); |
95 | void start(); | 102 | void start(); |
96 | void stop(); | 103 | void stop(); |
97 | void timerEvent( QTimerEvent *e ); | 104 | void timerEvent( QTimerEvent *e ); |
98 | 105 | ||
99 | private slots: | 106 | private slots: |
107 | void endPlaying(); | ||
108 | void endRecording(); | ||
100 | 109 | ||
101 | void FastforwardPressed(); | 110 | void FastforwardPressed(); |
102 | void FastforwardReleased(); | 111 | void FastforwardReleased(); |
112 | |||
103 | void changeDirCombo(int); | 113 | void changeDirCombo(int); |
104 | void changeSizeLimitCombo(int); | 114 | void changeSizeLimitCombo(int); |
105 | void changeTimeSlider(int); | 115 | void changeTimeSlider(int); |
106 | void changebitrateCombo(int); | 116 | void changebitrateCombo(int); |
107 | void changeStereoCheck( bool); | 117 | void changeStereoCheck( bool); |
108 | 118 | ||
109 | void changedInVolume(); | 119 | void changedInVolume(); |
110 | void changedOutVolume(); | 120 | void changedOutVolume(); |
111 | void changesamplerateCombo(int); | 121 | void changesamplerateCombo(int); |
122 | |||
112 | void cleanUp(); | 123 | void cleanUp(); |
113 | void compressionSelected(bool); | 124 | void compressionSelected(bool); |
114 | void deleteSound(); | 125 | void deleteSound(); |
115 | void doBeam(); | 126 | void doBeam(); |
116 | void doMenuPlay(); | 127 | void doMenuPlay(); |
117 | void doMicMuting(bool); | 128 | void doMicMuting(bool); |
118 | void doPlayBtn(); | 129 | void doPlayBtn(); |
119 | void doRename(); | 130 | void doRename(); |
120 | void doVolMuting(bool); | 131 | void doVolMuting(bool); |
121 | void forwardTimerTimeout(); | 132 | void forwardTimerTimeout(); |
122 | void itClick(QListViewItem *item); | 133 | void itClick(QListViewItem *item); |
123 | void listPressed(int, QListViewItem *, const QPoint&, int); | 134 | void listPressed(int, QListViewItem *, const QPoint&, int); |
124 | void newSound(); | 135 | void newSound(); |
125 | void rewindPressed(); | 136 | void rewindPressed(); |
126 | void rewindReleased(); | 137 | void rewindReleased(); |
127 | void rewindTimerTimeout(); | 138 | void rewindTimerTimeout(); |
128 | void slotAutoMute(bool); | 139 | void slotAutoMute(bool); |
129 | void thisTab(QWidget*); | 140 | void thisTab(QWidget*); |
130 | void timeSliderPressed(); | 141 | void timeSliderPressed(); |
131 | void timeSliderReleased(); | 142 | void timeSliderReleased(); |
132 | void timerBreak(); | 143 | void timerBreak(); |
133 | void initIconView(); | 144 | void initIconView(); |
134 | /* void changedOutVolume(int); */ | 145 | /* void changedOutVolume(int); */ |
135 | /* void changedInVolume(int); */ | 146 | /* void changedInVolume(int); */ |
136 | 147 | ||
137 | protected: | 148 | protected: |
138 | 149 | ||
139 | WavFile *wavFile; | 150 | WavFile *wavFile; |
140 | QButtonGroup *ButtonGroup1; | 151 | QButtonGroup *ButtonGroup1; |
141 | QCheckBox *outMuteCheckBox, *inMuteCheckBox, *compressionCheckBox, *autoMuteCheckBox, *stereoCheckBox; | 152 | QCheckBox *outMuteCheckBox, *inMuteCheckBox, *compressionCheckBox, *autoMuteCheckBox, *stereoCheckBox; |
142 | QComboBox* sampleRateComboBox, * bitRateComboBox, *directoryComboBox, *sizeLimitCombo; | 153 | QComboBox* sampleRateComboBox, * bitRateComboBox, *directoryComboBox, *sizeLimitCombo; |
143 | QHBoxLayout* Layout12; | 154 | QHBoxLayout* Layout12; |
144 | QHBoxLayout* Layout13; | 155 | QHBoxLayout* Layout13; |
145 | QHBoxLayout* Layout14; | 156 | QHBoxLayout* Layout14; |
146 | QHBoxLayout* Layout16; | 157 | QHBoxLayout* Layout16; |
147 | QHBoxLayout* Layout17; | 158 | QHBoxLayout* Layout17; |
148 | QHBoxLayout* Layout19; | 159 | QHBoxLayout* Layout19; |
149 | QIconView *IconView1; | 160 | QIconView *IconView1; |
150 | QLabel *NewSoundLabel,*playLabel2; | 161 | QLabel *NewSoundLabel,*playLabel2; |
151 | QLabel *TextLabel3, *TextLabel1, *TextLabel2; | 162 | QLabel *TextLabel3, *TextLabel1, *TextLabel2; |
152 | QListView *ListView1; | 163 | QListView *ListView1; |
153 | QPushButton *Stop_PushButton, *Play_PushButton, *Rec_PushButton, *NewSoundButton, *deleteSoundButton, *toBeginningButton, *toEndButton; | 164 | QPushButton *Stop_PushButton, *Play_PushButton, *Rec_PushButton, *NewSoundButton, *deleteSoundButton, *toBeginningButton, *toEndButton; |
154 | QString recDir; | 165 | QString recDir; |
155 | QTabWidget *TabWidget; | 166 | QTabWidget *TabWidget; |
156 | QTimer *t, *rewindTimer, *forwardTimer; | 167 | QTimer *t, *rewindTimer, *forwardTimer; |
157 | QVBoxLayout* Layout15; | 168 | QVBoxLayout* Layout15; |
158 | QVBoxLayout* Layout15b; | 169 | QVBoxLayout* Layout15b; |
159 | QVBoxLayout* Layout18; | 170 | QVBoxLayout* Layout18; |
160 | QWidget *tab, *tab_2, *tab_3, *tab_4, *tab_5; | 171 | QWidget *tab, *tab_2, *tab_3, *tab_4, *tab_5; |
161 | int sliderPos, total; | 172 | int sliderPos, total; |
162 | // short inbuffer[BUFSIZE], outbuffer[BUFSIZE]; | 173 | // short inbuffer[BUFSIZE], outbuffer[BUFSIZE]; |
163 | // unsigned short unsigned_inbuffer[BUFSIZE], unsigned_outbuffer[BUFSIZE]; | 174 | // unsigned short unsigned_inbuffer[BUFSIZE], unsigned_outbuffer[BUFSIZE]; |
164 | QGroupBox *sampleGroup, *bitGroup, *dirGroup, *sizeGroup; | 175 | QGroupBox *sampleGroup, *bitGroup, *dirGroup, *sizeGroup; |
165 | /* short inbuffer[65536], outbuffer[65536]; */ | 176 | /* short inbuffer[65536], outbuffer[65536]; */ |
166 | /* unsigned short unsigned_inbuffer[65536], unsigned_outbuffer[65536]; */ | 177 | /* unsigned short unsigned_inbuffer[65536], unsigned_outbuffer[65536]; */ |
167 | 178 | ||
168 | 179 | ||
169 | bool doPlay(); | 180 | bool doPlay(); |
170 | bool openPlayFile(); | 181 | bool openPlayFile(); |
171 | bool setUpFile(); | 182 | bool setUpFile(); |
172 | bool setupAudio( bool b); | 183 | bool setupAudio( bool b); |
173 | void endPlaying(); | ||
174 | void endRecording(); | ||
175 | void fileBeamFinished( Ir *ir); | 184 | void fileBeamFinished( Ir *ir); |
176 | void keyPressEvent( QKeyEvent *e); | 185 | void keyPressEvent( QKeyEvent *e); |
177 | void keyReleaseEvent( QKeyEvent *e); | 186 | void keyReleaseEvent( QKeyEvent *e); |
178 | void receive( const QCString &, const QByteArray & ); | 187 | void receive( const QCString &, const QByteArray & ); |
179 | void showListMenu(QListViewItem * ); | 188 | void showListMenu(QListViewItem * ); |
180 | #ifndef THREADED | 189 | #ifndef THREADED |
181 | void quickRec(); | 190 | void quickRec(); |
182 | void playIt(); | 191 | void playIt(); |
183 | #endif | 192 | #endif |
184 | 193 | ||
185 | }; | 194 | }; |
186 | 195 | ||
187 | #endif // QTREC_H | 196 | #endif // QTREC_H |
diff --git a/noncore/multimedia/opierec/wavFile.cpp b/noncore/multimedia/opierec/wavFile.cpp index b53c416..a0423f0 100644 --- a/noncore/multimedia/opierec/wavFile.cpp +++ b/noncore/multimedia/opierec/wavFile.cpp | |||
@@ -59,256 +59,256 @@ bool WavFile::newFile() { | |||
59 | QString currentFile=date; | 59 | QString currentFile=date; |
60 | if(currentFileName.right(1).find("/",0,true) == -1) | 60 | if(currentFileName.right(1).find("/",0,true) == -1) |
61 | currentFileName += "/" + date; | 61 | currentFileName += "/" + date; |
62 | else | 62 | else |
63 | currentFileName += date; | 63 | currentFileName += date; |
64 | currentFileName+=".wav"; | 64 | currentFileName+=".wav"; |
65 | 65 | ||
66 | // odebug << "set up file for recording: "+currentFileName << oendl; | 66 | // odebug << "set up file for recording: "+currentFileName << oendl; |
67 | char pointer[] = "/tmp/opierec-XXXXXX"; | 67 | char pointer[] = "/tmp/opierec-XXXXXX"; |
68 | int fd = 0; | 68 | int fd = 0; |
69 | 69 | ||
70 | if( currentFileName.find("/mnt",0,true) == -1 | 70 | if( currentFileName.find("/mnt",0,true) == -1 |
71 | && currentFileName.find("/tmp",0,true) == -1 ) { | 71 | && currentFileName.find("/tmp",0,true) == -1 ) { |
72 | // if destination file is most likely in flash (assuming jffs2) | 72 | // if destination file is most likely in flash (assuming jffs2) |
73 | // we have to write to a different filesystem first | 73 | // we have to write to a different filesystem first |
74 | 74 | ||
75 | useTmpFile = true; | 75 | useTmpFile = true; |
76 | if(( fd = mkstemp( pointer)) < 0 ) { | 76 | if(( fd = mkstemp( pointer)) < 0 ) { |
77 | perror("mkstemp failed"); | 77 | perror("mkstemp failed"); |
78 | return false; | 78 | return false; |
79 | } | 79 | } |
80 | 80 | ||
81 | // odebug << "Opening tmp file " << pointer << "" << oendl; | 81 | // odebug << "Opening tmp file " << pointer << "" << oendl; |
82 | track.setName( pointer); | 82 | track.setName( pointer); |
83 | 83 | ||
84 | } else { //just use regular file.. no moving | 84 | } else { //just use regular file.. no moving |
85 | 85 | ||
86 | useTmpFile = false; | 86 | useTmpFile = false; |
87 | track.setName( currentFileName); | 87 | track.setName( currentFileName); |
88 | } | 88 | } |
89 | if(!track.open( IO_ReadWrite | IO_Truncate)) { | 89 | if(!track.open( IO_ReadWrite | IO_Truncate)) { |
90 | QString errorMsg=(QString)strerror(errno); | 90 | QString errorMsg=(QString)strerror(errno); |
91 | odebug << errorMsg << oendl; | 91 | odebug << errorMsg << oendl; |
92 | QMessageBox::message("Note", "Error opening file.\n" +errorMsg); | 92 | QMessageBox::message("Note", "Error opening file.\n" +errorMsg); |
93 | 93 | ||
94 | return false; | 94 | return false; |
95 | } else { | 95 | } else { |
96 | setWavHeader( track.handle() , &hdr); | 96 | setWavHeader( track.handle() , &hdr); |
97 | } | 97 | } |
98 | return true; | 98 | return true; |
99 | } | 99 | } |
100 | 100 | ||
101 | WavFile::~WavFile() { | 101 | WavFile::~WavFile() { |
102 | 102 | ||
103 | closeFile(); | 103 | closeFile(); |
104 | } | 104 | } |
105 | 105 | ||
106 | void WavFile::closeFile() { | 106 | void WavFile::closeFile() { |
107 | if(track.isOpen()) | 107 | if(track.isOpen()) |
108 | track.close(); | 108 | track.close(); |
109 | } | 109 | } |
110 | 110 | ||
111 | int WavFile::openFile(const QString ¤tFileName) { | 111 | int WavFile::openFile(const QString ¤tFileName) { |
112 | qWarning("open play file "+currentFileName);; | 112 | qWarning("open play file "+currentFileName);; |
113 | closeFile(); | 113 | closeFile(); |
114 | 114 | ||
115 | track.setName(currentFileName); | 115 | track.setName(currentFileName); |
116 | 116 | ||
117 | if(!track.open(IO_ReadOnly)) { | 117 | if(!track.open(IO_ReadOnly)) { |
118 | QString errorMsg=(QString)strerror(errno); | 118 | QString errorMsg=(QString)strerror(errno); |
119 | odebug << "<<<<<<<<<<< "+errorMsg+currentFileName << oendl; | 119 | odebug << "<<<<<<<<<<< "+errorMsg+currentFileName << oendl; |
120 | QMessageBox::message("Note", "Error opening file.\n" +errorMsg); | 120 | QMessageBox::message("Note", "Error opening file.\n" +errorMsg); |
121 | return -1; | 121 | return -1; |
122 | } else { | 122 | } else { |
123 | parseWavHeader( track.handle()); | 123 | parseWavHeader( track.handle()); |
124 | } | 124 | } |
125 | return track.handle(); | 125 | return track.handle(); |
126 | } | 126 | } |
127 | 127 | ||
128 | bool WavFile::setWavHeader(int fd, wavhdr *hdr) { | 128 | bool WavFile::setWavHeader(int fd, wavhdr *hdr) { |
129 | 129 | ||
130 | strncpy((*hdr).riffID, "RIFF", 4); // RIFF | 130 | strncpy((*hdr).riffID, "RIFF", 4); // RIFF |
131 | strncpy((*hdr).wavID, "WAVE", 4); //WAVE | 131 | strncpy((*hdr).wavID, "WAVE", 4); //WAVE |
132 | strncpy((*hdr).fmtID, "fmt ", 4); // fmt | 132 | strncpy((*hdr).fmtID, "fmt ", 4); // fmt |
133 | (*hdr).fmtLen = 16; // format length = 16 | 133 | (*hdr).fmtLen = 16; // format length = 16 |
134 | 134 | ||
135 | if( wavFormat == WAVE_FORMAT_PCM) { | 135 | if( wavFormat == WAVE_FORMAT_PCM) { |
136 | (*hdr).fmtTag = 1; // PCM | 136 | (*hdr).fmtTag = 1; // PCM |
137 | // odebug << "set header WAVE_FORMAT_PCM" << oendl; | 137 | // odebug << "set header WAVE_FORMAT_PCM" << oendl; |
138 | } | 138 | } |
139 | else { | 139 | else { |
140 | (*hdr).fmtTag = WAVE_FORMAT_DVI_ADPCM; //intel ADPCM | 140 | (*hdr).fmtTag = WAVE_FORMAT_DVI_ADPCM; //intel ADPCM |
141 | // odebug << "set header WAVE_FORMAT_DVI_ADPCM" << oendl; | 141 | // odebug << "set header WAVE_FORMAT_DVI_ADPCM" << oendl; |
142 | } | 142 | } |
143 | 143 | ||
144 | // (*hdr).nChannels = 1;//filePara.channels;// ? 2 : 1*/; // channels | 144 | // (*hdr).nChannels = 1;//filePara.channels;// ? 2 : 1*/; // channels |
145 | (*hdr).nChannels = wavChannels;// ? 2 : 1*/; // channels | 145 | (*hdr).nChannels = wavChannels;// ? 2 : 1*/; // channels |
146 | 146 | ||
147 | (*hdr).sampleRate = wavSampleRate; //samples per second | 147 | (*hdr).sampleRate = wavSampleRate; //samples per second |
148 | (*hdr).avgBytesPerSec = (wavSampleRate)*( wavChannels*(wavResolution/8)); // bytes per second | 148 | (*hdr).avgBytesPerSec = (wavSampleRate)*( wavChannels*(wavResolution/8)); // bytes per second |
149 | (*hdr).nBlockAlign = wavChannels*( wavResolution/8); //block align | 149 | (*hdr).nBlockAlign = wavChannels*( wavResolution/8); //block align |
150 | (*hdr).bitsPerSample = wavResolution; //bits per sample 8, or 16 | 150 | (*hdr).bitsPerSample = wavResolution; //bits per sample 8, or 16 |
151 | 151 | ||
152 | strncpy((*hdr).dataID, "data", 4); | 152 | strncpy((*hdr).dataID, "data", 4); |
153 | 153 | ||
154 | write( fd,hdr, sizeof(*hdr)); | 154 | write( fd,hdr, sizeof(*hdr)); |
155 | owarn << "writing header: bitrate " << wavResolution << ", samplerate " << wavSampleRate << ", channels " << wavChannels << oendl; | 155 | // owarn << "writing header: bitrate " << wavResolution << ", samplerate " << wavSampleRate << ", channels " << wavChannels << oendl; |
156 | return true; | 156 | return true; |
157 | } | 157 | } |
158 | 158 | ||
159 | bool WavFile::adjustHeaders(int fd, int total) { | 159 | bool WavFile::adjustHeaders(int fd, int total) { |
160 | lseek(fd, 4, SEEK_SET); | 160 | lseek(fd, 4, SEEK_SET); |
161 | int i = total + 36; | 161 | int i = total + 36; |
162 | write( fd, &i, sizeof(i)); | 162 | write( fd, &i, sizeof(i)); |
163 | lseek( fd, 40, SEEK_SET); | 163 | lseek( fd, 40, SEEK_SET); |
164 | write( fd, &total, sizeof(total)); | 164 | write( fd, &total, sizeof(total)); |
165 | owarn << "adjusting header " << total << "" << oendl; | 165 | // owarn << "adjusting header " << total << "" << oendl; |
166 | return true; | 166 | return true; |
167 | } | 167 | } |
168 | 168 | ||
169 | int WavFile::parseWavHeader(int fd) { | 169 | int WavFile::parseWavHeader(int fd) { |
170 | owarn << "Parsing wav header" << oendl; | 170 | // owarn << "Parsing wav header" << oendl; |
171 | char string[4]; | 171 | char string[4]; |
172 | int found; | 172 | int found; |
173 | short fmt; | 173 | short fmt; |
174 | unsigned short ch, bitrate; | 174 | unsigned short ch, bitrate; |
175 | unsigned long samplerrate, longdata; | 175 | unsigned long samplerrate, longdata; |
176 | 176 | ||
177 | if (read(fd, string, 4) < 4) { | 177 | if (read(fd, string, 4) < 4) { |
178 | owarn << " Could not read from sound file." << oendl; | 178 | // owarn << " Could not read from sound file." << oendl; |
179 | return -1; | 179 | return -1; |
180 | } | 180 | } |
181 | if (strncmp(string, "RIFF", 4)) { | 181 | if (strncmp(string, "RIFF", 4)) { |
182 | owarn << " not a valid WAV file." << oendl; | 182 | // owarn << " not a valid WAV file." << oendl; |
183 | return -1; | 183 | return -1; |
184 | } | 184 | } |
185 | lseek(fd, 4, SEEK_CUR); | 185 | lseek(fd, 4, SEEK_CUR); |
186 | if (read(fd, string, 4) < 4) { | 186 | if (read(fd, string, 4) < 4) { |
187 | owarn << "Could not read from sound file." << oendl; | 187 | // owarn << "Could not read from sound file." << oendl; |
188 | return -1; | 188 | return -1; |
189 | } | 189 | } |
190 | if (strncmp(string, "WAVE", 4)) { | 190 | if (strncmp(string, "WAVE", 4)) { |
191 | owarn << "not a valid WAV file." << oendl; | 191 | // owarn << "not a valid WAV file." << oendl; |
192 | return -1; | 192 | return -1; |
193 | } | 193 | } |
194 | found = 0; | 194 | found = 0; |
195 | 195 | ||
196 | while (!found) { | 196 | while (!found) { |
197 | if (read(fd, string, 4) < 4) { | 197 | if (read(fd, string, 4) < 4) { |
198 | owarn << "Could not read from sound file." << oendl; | 198 | // owarn << "Could not read from sound file." << oendl; |
199 | return -1; | 199 | return -1; |
200 | } | 200 | } |
201 | if (strncmp(string, "fmt ", 4)) { | 201 | if (strncmp(string, "fmt ", 4)) { |
202 | if (read(fd, &longdata, 4) < 4) { | 202 | if (read(fd, &longdata, 4) < 4) { |
203 | owarn << "Could not read from sound file." << oendl; | 203 | // owarn << "Could not read from sound file." << oendl; |
204 | return -1; | 204 | return -1; |
205 | } | 205 | } |
206 | lseek(fd, longdata, SEEK_CUR); | 206 | lseek(fd, longdata, SEEK_CUR); |
207 | } else { | 207 | } else { |
208 | lseek(fd, 4, SEEK_CUR); | 208 | lseek(fd, 4, SEEK_CUR); |
209 | if (read(fd, &fmt, 2) < 2) { | 209 | if (read(fd, &fmt, 2) < 2) { |
210 | owarn << "Could not read format chunk." << oendl; | 210 | // owarn << "Could not read format chunk." << oendl; |
211 | return -1; | 211 | return -1; |
212 | } | 212 | } |
213 | if (fmt != WAVE_FORMAT_PCM && fmt != WAVE_FORMAT_DVI_ADPCM) { | 213 | if (fmt != WAVE_FORMAT_PCM && fmt != WAVE_FORMAT_DVI_ADPCM) { |
214 | owarn << "Wave file contains unknown format. Unable to continue." << oendl; | 214 | // owarn << "Wave file contains unknown format. Unable to continue." << oendl; |
215 | return -1; | 215 | return -1; |
216 | } | 216 | } |
217 | wavFormat = fmt; | 217 | wavFormat = fmt; |
218 | // compressionFormat=fmt; | 218 | // compressionFormat=fmt; |
219 | owarn << "compressionFormat is " << fmt << "" << oendl; | 219 | // owarn << "compressionFormat is " << fmt << "" << oendl; |
220 | if (read(fd, &ch, 2) < 2) { | 220 | if (read(fd, &ch, 2) < 2) { |
221 | owarn << "Could not read format chunk." << oendl; | 221 | // owarn << "Could not read format chunk." << oendl; |
222 | return -1; | 222 | return -1; |
223 | } else { | 223 | } else { |
224 | wavChannels = ch; | 224 | wavChannels = ch; |
225 | owarn << "File has " << ch << " channels" << oendl; | 225 | // owarn << "File has " << ch << " channels" << oendl; |
226 | } | 226 | } |
227 | if (read(fd, &samplerrate, 4) < 4) { | 227 | if (read(fd, &samplerrate, 4) < 4) { |
228 | owarn << "Could not read from format chunk." << oendl; | 228 | // owarn << "Could not read from format chunk." << oendl; |
229 | return -1; | 229 | return -1; |
230 | } else { | 230 | } else { |
231 | wavSampleRate = samplerrate; | 231 | wavSampleRate = samplerrate; |
232 | // sampleRate = samplerrate; | 232 | // sampleRate = samplerrate; |
233 | owarn << "File has samplerate of " << (int) samplerrate << "" << oendl; | 233 | // owarn << "File has samplerate of " << (int) samplerrate << "" << oendl; |
234 | } | 234 | } |
235 | lseek(fd, 6, SEEK_CUR); | 235 | lseek(fd, 6, SEEK_CUR); |
236 | if (read(fd, &bitrate, 2) < 2) { | 236 | if (read(fd, &bitrate, 2) < 2) { |
237 | owarn << "Could not read format chunk." << oendl; | 237 | // owarn << "Could not read format chunk." << oendl; |
238 | return -1; | 238 | return -1; |
239 | } else { | 239 | } else { |
240 | wavResolution=bitrate; | 240 | wavResolution=bitrate; |
241 | // resolution = bitrate; | 241 | // resolution = bitrate; |
242 | owarn << "File has bitrate of " << bitrate << "" << oendl; | 242 | // owarn << "File has bitrate of " << bitrate << "" << oendl; |
243 | } | 243 | } |
244 | found++; | 244 | found++; |
245 | } | 245 | } |
246 | } | 246 | } |
247 | found = 0; | 247 | found = 0; |
248 | while (!found) { | 248 | while (!found) { |
249 | if (read(fd, string, 4) < 4) { | 249 | if (read(fd, string, 4) < 4) { |
250 | odebug << "Could not read from sound file." << oendl; | 250 | odebug << "Could not read from sound file." << oendl; |
251 | return -1; | 251 | return -1; |
252 | } | 252 | } |
253 | 253 | ||
254 | if (strncmp(string, "data", 4)) { | 254 | if (strncmp(string, "data", 4)) { |
255 | if (read(fd, &longdata, 4)<4) { | 255 | if (read(fd, &longdata, 4)<4) { |
256 | odebug << "Could not read from sound file." << oendl; | 256 | odebug << "Could not read from sound file." << oendl; |
257 | return -1; | 257 | return -1; |
258 | } | 258 | } |
259 | 259 | ||
260 | lseek(fd, longdata, SEEK_CUR); | 260 | lseek(fd, longdata, SEEK_CUR); |
261 | } else { | 261 | } else { |
262 | if (read(fd, &longdata, 4) < 4) { | 262 | if (read(fd, &longdata, 4) < 4) { |
263 | odebug << "Could not read from sound file." << oendl; | 263 | odebug << "Could not read from sound file." << oendl; |
264 | return -1; | 264 | return -1; |
265 | } else { | 265 | } else { |
266 | wavNumberSamples = longdata; | 266 | wavNumberSamples = longdata; |
267 | odebug << "file hase length of " << (int)longdata << "" | 267 | odebug << "file hase length of " << (int)longdata << "" |
268 | << "lasting " | 268 | << "lasting " |
269 | << (int)(( longdata / wavSampleRate) / wavChannels) / ( wavChannels*( wavResolution/8)) | 269 | << (int)(( longdata / wavSampleRate) / wavChannels) / ( wavChannels*( wavResolution/8)) |
270 | << " seconds" << oendl; | 270 | << " seconds" << oendl; |
271 | // wavSeconds = (( longdata / wavSampleRate) / wavChannels) / ( wavChannels*( wavResolution/8)); | 271 | // wavSeconds = (( longdata / wavSampleRate) / wavChannels) / ( wavChannels*( wavResolution/8)); |
272 | 272 | ||
273 | return longdata; | 273 | return longdata; |
274 | } | 274 | } |
275 | } | 275 | } |
276 | } | 276 | } |
277 | 277 | ||
278 | lseek(fd, 0, SEEK_SET); | 278 | lseek(fd, 0, SEEK_SET); |
279 | 279 | ||
280 | return 0; | 280 | return 0; |
281 | } | 281 | } |
282 | 282 | ||
283 | QString WavFile::trackName() { | 283 | QString WavFile::trackName() { |
284 | return track.name(); | 284 | return track.name(); |
285 | } | 285 | } |
286 | 286 | ||
287 | int WavFile::wavHandle(){ | 287 | int WavFile::wavHandle(){ |
288 | return track.handle(); | 288 | return track.handle(); |
289 | } | 289 | } |
290 | 290 | ||
291 | int WavFile::getFormat() { | 291 | int WavFile::getFormat() { |
292 | return wavFormat; | 292 | return wavFormat; |
293 | } | 293 | } |
294 | 294 | ||
295 | int WavFile::getResolution() { | 295 | int WavFile::getResolution() { |
296 | return wavResolution; | 296 | return wavResolution; |
297 | } | 297 | } |
298 | 298 | ||
299 | int WavFile::getSampleRate() { | 299 | int WavFile::getSampleRate() { |
300 | return wavSampleRate; | 300 | return wavSampleRate; |
301 | } | 301 | } |
302 | 302 | ||
303 | int WavFile::getNumberSamples() { | 303 | int WavFile::getNumberSamples() { |
304 | return wavNumberSamples; | 304 | return wavNumberSamples; |
305 | } | 305 | } |
306 | 306 | ||
307 | bool WavFile::isTempFile() { | 307 | bool WavFile::isTempFile() { |
308 | return useTmpFile; | 308 | return useTmpFile; |
309 | } | 309 | } |
310 | 310 | ||
311 | int WavFile::getChannels() { | 311 | int WavFile::getChannels() { |
312 | 312 | ||
313 | return wavChannels; | 313 | return wavChannels; |
314 | } | 314 | } |