From d75f4b44848233723d13cf92b05b15b5d134502d Mon Sep 17 00:00:00 2001 From: Ravindra Kumar Mishra Date: Wed, 17 Apr 2013 13:06:17 +0530 Subject: [PATCH] PitchMap UX improvement Signed-off-by: Ravindra Kumar Mishra --- project/inc/PcmPitchControl.h | 8 ++++- project/src/Codec/AudioDecoderForm.cpp | 7 +++- project/src/Codec/AudioEncoderForm.cpp | 5 +++ project/src/PcmPitchControl.cpp | 60 ++++++++++++++++++++++++++++------ 4 files changed, 68 insertions(+), 12 deletions(-) diff --git a/project/inc/PcmPitchControl.h b/project/inc/PcmPitchControl.h index bb80aea..e17a8a7 100644 --- a/project/inc/PcmPitchControl.h +++ b/project/inc/PcmPitchControl.h @@ -24,7 +24,9 @@ #include #include -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_ diff --git a/project/src/Codec/AudioDecoderForm.cpp b/project/src/Codec/AudioDecoderForm.cpp index 14a80ac..d37e4bc 100644 --- a/project/src/Codec/AudioDecoderForm.cpp +++ b/project/src/Codec/AudioDecoderForm.cpp @@ -654,6 +654,8 @@ AudioDecoderForm::EnableSelectedSoftKey(void) result AudioDecoderForm::StartAudioDecoding(void) { + AppLog(" StartDecodingAAC ENTER"); + result r = E_SUCCESS; String fileName; unique_ptr 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"); diff --git a/project/src/Codec/AudioEncoderForm.cpp b/project/src/Codec/AudioEncoderForm.cpp index 94eca2e..10b2ba8 100644 --- a/project/src/Codec/AudioEncoderForm.cpp +++ b/project/src/Codec/AudioEncoderForm.cpp @@ -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"; diff --git a/project/src/PcmPitchControl.cpp b/project/src/PcmPitchControl.cpp index c11efef..ec6941d 100644 --- a/project/src/PcmPitchControl.cpp +++ b/project/src/PcmPitchControl.cpp @@ -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)); } } -- 2.7.4