SilentEye 0.4.1

modules/seformatwav/seformatwav.cpp

Go to the documentation of this file.
00001 //  This file is part of SilentEye.
00002 //
00003 //  SilentEye is free software: you can redistribute it and/or modify
00004 //  it under the terms of the GNU General Public License as published by
00005 //  the Free Software Foundation, either version 3 of the License, or
00006 //  (at your option) any later version.
00007 //
00008 //  SilentEye is distributed in the hope that it will be useful,
00009 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 //  GNU General Public License for more details.
00012 //
00013 //  You should have received a copy of the GNU General Public License
00014 //  along with SilentEye.  If not, see <http://www.gnu.org/licenses/>.
00015 
00016 #include "seformatwav.h"
00017 
00018 namespace SEFormatWAV {
00019 
00020     SEFormatWav::SEFormatWav()
00021     {
00022         this->setObjectName("SEFormatWav");
00023         m_logger = new Logger(this);
00024 
00025         m_encodeWidget = NULL;
00026         m_decodeWidget = NULL;
00027     }
00028 
00029     SEFormatWav::~SEFormatWav()
00030     {
00031         if (m_encodeWidget != NULL)
00032             delete m_encodeWidget;
00033         if (m_decodeWidget != NULL)
00034             delete m_decodeWidget;
00035         delete m_logger;
00036     }
00037 
00038     QString SEFormatWav::name() const
00039     {
00040         return QString("Silent Eye Audio Format WAVE");
00041     }
00042 
00043     QString SEFormatWav::version() const
00044     {
00045         return QString("1.1");
00046     }
00047 
00048     QString SEFormatWav::status()
00049     {
00050         return "OK|";
00051     }
00052 
00053     QWidget* SEFormatWav::encodeWidget()
00054     {
00055         if (m_encodeWidget == NULL)
00056         {
00057             m_encodeWidget = new OptionWidget();
00058             m_encodeWidget->setObjectName("EncodeWidget");
00059             connect(m_encodeWidget, SIGNAL(optionHasChanged()), this, SLOT(optionHasChanged()));
00060         }
00061         return m_encodeWidget;
00062     }
00063 
00064     QWidget* SEFormatWav::decodeWidget()
00065     {
00066         if (m_decodeWidget == NULL)
00067         {
00068             m_decodeWidget = new OptionWidget();
00069             m_decodeWidget->setObjectName("DecodeWidget");
00070         }
00071         return m_decodeWidget;
00072     }
00073 
00074     QPointer<Audio> SEFormatWav::encodeAudio(QPointer<Audio> audio, bool dontDuplicate)
00075     {
00076         return updateAudio(audio, (OptionWidget*) encodeWidget(), dontDuplicate);
00077     }
00078 
00079     QPointer<Audio> SEFormatWav::decodeAudio(QPointer<Audio> audio, bool dontDuplicate)
00080     {
00081         return updateAudio(audio, (OptionWidget*) decodeWidget(), dontDuplicate);
00082     }
00083 
00084     QPointer<Audio> SEFormatWav::updateAudio(QPointer<Audio> aud, OptionWidget* w, bool dontDuplicate)
00085     {
00086         QPointer<Audio> wav;
00087         if (dontDuplicate)
00088         {
00089             wav = new AudioWav(aud); // don't copy wave data
00090         }
00091         else
00092         {
00093             wav = new AudioWav(*aud); // duplicate wave into a new one
00094         }
00095 
00096         AudioWav* newAudio = ((AudioWav*)wav.data());
00097 
00098         newAudio->setNbBitsUsed(w->nbBits());
00099         newAudio->setNbChannelUsed(w->channels());
00100         newAudio->setDistribution(w->distribution());
00101         newAudio->setHeaderPosition(w->headerPosition());
00102 
00103         return wav;
00104     }
00105 
00106 
00107     QString SEFormatWav::typeSupported() const
00108     {
00109         return QString("WAVE");
00110     }
00111 
00112     bool SEFormatWav::isEncodeWidgetReady() const
00113     {
00114         return true;
00115     }
00116 
00117     bool SEFormatWav::isDecodeWidgetReady() const
00118     {
00119         return true;
00120     }
00121 
00122     void SEFormatWav::optionHasChanged()
00123     {
00124         emit optionChanged();
00125     }
00126 
00127     }
00128 
00129 Q_EXPORT_PLUGIN2(seformatwav, SEFormatWAV::SEFormatWav)