PitchMap UX improvement
authorRavindra Kumar Mishra <ravindra.m@samsung.com>
Wed, 17 Apr 2013 07:36:17 +0000 (13:06 +0530)
committerRavindra Kumar Mishra <ravindra.m@samsung.com>
Wed, 17 Apr 2013 07:36:17 +0000 (13:06 +0530)
Signed-off-by: Ravindra Kumar Mishra <ravindra.m@samsung.com>
project/inc/PcmPitchControl.h
project/src/Codec/AudioDecoderForm.cpp
project/src/Codec/AudioEncoderForm.cpp
project/src/PcmPitchControl.cpp

index bb80aea..e17a8a7 100644 (file)
@@ -24,7 +24,9 @@
 #include <FMediaAudioTypes.h>
 #include <FMediaTypes.h>
 
-const int AMPLIFICATION_FACTOR = 2;
+const int AMPLIFICATION_FACTOR = 3;
+const int DEFAULT_SAMPLE_SIZE = 2;
+const int SAMPLES_PER_FRAME_FOR_PITCHMAP = 1;
 
 class PcmPitchControl
        : public Tizen::Ui::Container
@@ -43,7 +45,11 @@ protected:
        virtual result OnDraw(void);
        Tizen::Base::ByteBuffer* __pBuf1;
        Tizen::Base::ByteBuffer* __pBuf2;
+       Tizen::Base::ByteBuffer __decodedPcmPitchBuf;
+       Tizen::Base::ByteBuffer __SrcPcmPitchBuf;
        int __sampleSize;
+       int __sampleCount;
+       int __sampleCount1;
 };
 
 #endif // _PCMPITCH_CONTROL_H_
index 14a80ac..d37e4bc 100644 (file)
@@ -654,6 +654,8 @@ AudioDecoderForm::EnableSelectedSoftKey(void)
 result
 AudioDecoderForm::StartAudioDecoding(void)
 {
+       AppLog(" StartDecodingAAC ENTER");
+
        result r = E_SUCCESS;
        String fileName;
        unique_ptr<HashMap> pOption;
@@ -662,7 +664,10 @@ AudioDecoderForm::StartAudioDecoding(void)
        Tizen::Media::AudioSampleType sampleType = AUDIO_TYPE_NONE;
        Tizen::Media::AudioChannelType channelType = AUDIO_CHANNEL_TYPE_NONE;
 
-       AppLog(" StartDecodingAAC ENTER");
+       if(__pPcmPitchCtrl != null)
+       {
+               __pPcmPitchCtrl->Clear();
+       }
        __pDec = new (std::nothrow) AudioDecoder();
        TryCatch(__pDec != null, r = E_OUT_OF_MEMORY, "Error Occurred");
 
index 94eca2e..10b2ba8 100644 (file)
@@ -869,6 +869,11 @@ AudioEncoderForm::StartAudioDecoding(void)
        Tizen::Media::AudioSampleType sampleType = AUDIO_TYPE_NONE;
        Tizen::Media::AudioChannelType channelType = AUDIO_CHANNEL_TYPE_NONE;
 
+       if(__pPcmPitchCtrl != null)
+       {
+               __pPcmPitchCtrl->Clear();
+       }
+
        if(__audioCodecId == CODEC_AAC)
        {
                __decoderFilePath = App::GetInstance()->GetAppRootPath() + L"data/test_aac_enc_wav.aac";
index c11efef..ec6941d 100644 (file)
@@ -26,6 +26,8 @@ PcmPitchControl::PcmPitchControl(void)
        : __pBuf1(null)
        , __pBuf2(null)
        , __sampleSize(0)
+       , __sampleCount(0)
+    , __sampleCount1(0)
 {
 }
 
@@ -60,6 +62,12 @@ PcmPitchControl::Construct(const Tizen::Graphics::Rectangle& rect)
        result r = E_SUCCESS;
        r = Container::Construct(rect, true);
        TryReturn(E_SUCCESS == r, r , "[%s] Propagated.", GetErrorMessage(r));
+
+       int width = rect.width;
+       r = __decodedPcmPitchBuf.Construct(width*DEFAULT_SAMPLE_SIZE);
+       TryReturn(E_SUCCESS == r, r , "[%s] Propagated.", GetErrorMessage(r));
+       r = __SrcPcmPitchBuf.Construct(width*DEFAULT_SAMPLE_SIZE);
+       TryReturn(E_SUCCESS == r, r , "[%s] Propagated.", GetErrorMessage(r));
        return r;
 }
 
@@ -76,6 +84,7 @@ PcmPitchControl::SetSampleSize(Tizen::Media::AudioSampleType sampleType)
        {
                __sampleSize = 2;
        }
+
        return r;
 }
 
@@ -99,6 +108,10 @@ PcmPitchControl::Clear(void)
        pCanvas->Clear();
        pCanvas->Show();
 
+       __decodedPcmPitchBuf.Clear();
+       __SrcPcmPitchBuf.Clear();
+       __sampleCount = 0;
+       __sampleCount1 = 0;
 CATCH:
        SAFE_DELETE(pCanvas);
        return r;
@@ -126,12 +139,6 @@ PcmPitchControl::OnDraw(void)
 
        if (__pBuf1 != null)
        {
-               int length = __pBuf1->GetLimit();
-               int samplesCount = length/__sampleSize;
-
-               int limit = samplesCount > width ? width : samplesCount;
-               int start = samplesCount > width ? 0 : (width-samplesCount)/2;
-
                pCanvas = GetCanvasN();
                TryCatch(pCanvas, r = GetLastResult(), "GetCanvasN failed:%s", GetErrorMessage(GetLastResult()));
 
@@ -155,13 +162,30 @@ PcmPitchControl::OnDraw(void)
                //Draw the BaseLine for first PCM Pitch
                pCanvas->DrawLine(Point(0,base),Point(width-1,base));
 
+               //Draw first PCM PitchMap
+               int limit = 0;
+
+               for(int i=0 ; i< SAMPLES_PER_FRAME_FOR_PITCHMAP; i=i+1)
+               {
+                       __pBuf1->GetShort(i*sizeof(short),value);
+                       __decodedPcmPitchBuf.SetShort(value);
+                       __sampleCount++;
+                       limit =  (__sampleCount > width) ? width : __sampleCount;
+                       if(__sampleCount == width)
+                       {
+                               __decodedPcmPitchBuf.SetPosition(0);
+                       }
+
+               }
+
                for(int i=0 ; i< limit ; i=i+1)
                {
-                       __pBuf1->GetShort(2*i,value);
+                       __decodedPcmPitchBuf.GetShort(i*sizeof(short),value);
                        int offset = (value*height1*AMPLIFICATION_FACTOR)/0xFFFF;
-                       pCanvas->DrawLine(Point(x+i+start,base),Point(x+i+start,base-offset));
+                       pCanvas->DrawLine(Point(x+i,base),Point(x+i,base-offset));
                }
 
+
                if(__pBuf2 != null)
                {
 
@@ -169,11 +193,27 @@ PcmPitchControl::OnDraw(void)
                        pCanvas->DrawLine(Point(0,base1),Point(width-1,base1));
                        pCanvas->DrawText(Point(x,y+height1),L"DECODED PCM PITCHMAP");
 
+                       //Draw Second PCM PitchMap
+                       limit = 0;
+                       for(int i=0 ; i< SAMPLES_PER_FRAME_FOR_PITCHMAP; i=i+1)
+                       {
+                               __pBuf2->GetShort(i*sizeof(short),value);
+                               __SrcPcmPitchBuf.SetShort(value);
+                               __SrcPcmPitchBuf.GetPosition();
+                               __sampleCount1++;
+                               limit =  (__sampleCount1 > width) ? width : __sampleCount1;
+
+                               if(__sampleCount1 == width)
+                               {
+                                       __SrcPcmPitchBuf.SetPosition(0);
+                               }
+                       }
+
                        for(int i=0 ; i< limit ; i=i+1)
                        {
-                               __pBuf2->GetShort(2*i,value);
+                               __SrcPcmPitchBuf.GetShort(i*sizeof(short),value);
                                int offset1 = (value*height1*AMPLIFICATION_FACTOR)/0xFFFF;
-                               pCanvas->DrawLine(Point(x+i+start,base1),Point(x+i+start,base1-offset1));
+                               pCanvas->DrawLine(Point(x+i,base1),Point(x+i,base1-offset1));
                        }
 
                }