SlideShare une entreprise Scribd logo
1  sur  54
Télécharger pour lire hors ligne
Sounds in bada




             Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   1
Contents
       Introduction
       Common Sound Classes
         – AudioRecorder/Player
         – AudioIn/AudioOut
       Simple Mixing
       Media Management
         – Image
         – Video
         – Streaming
       Summary
*This material is based on bada SDK 1.0.0b3
                                              Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   2
Media Introduction
 Audio/ video/ image processing functions
 Key features

      Audio              Video                                       Image
 • Playback         • Playback                          • Load
 • Record           • Record                            • Save
 • Streaming        • Streaming                         • Format conversion
 • PCM processing   • Camera capture
                    • Camera preview




                                 Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   3
Supported Formats
Type                Format                   Encode                Decode                Streaming*
Video H.263, MPEG-4 (.3gp, mp4)                     O                    O                         O
       H.264 (.3gp, mp4)                                                 O                         O
       VC-1 (.wmv, .asf)                                                 O
Audio PCM (.wav)                                    O                    O
       AMR-NB (.amr, .3ga, .m4a)                    O                    O                         O
       AAC, AAC+, EAAC+                                                  O                         O
       (.aac, .3ga, .m4a)
       MIDI (.mid, .spm, .imy, .mmf, .xmf)                               O
       MP3 (.mp3), WMA ( .wma, .asf)                                     O
Image JPEG, PNG, BMP                                O                    O
       GIF, TIFF, WBMP                                                   O


                                                            *Streaming Protocol: RTSP
                                             Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   4
Header & Library
 Header file:
 – #include <FMedia.h>
 Library
 – Simulator: FMedia
 – Target: FOsp
 Privilege groups
 – RECORDING
 – IMAGE
 – CAMERA
                         Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   5
Common Sound Classes




                 Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   6
Audio Recorder & Player
    Basic method                     Complex method
    :General purpose                 :Direct access to device

       Recording                        Recording
        – AudioRecorder : Records         – AudioIn : Read raw PCM
          audio data from input             data from input srouce
          source to storage
       Playing                          Playing
        – Player : Open audio file        – AudioOut : Play sound with
          and play                          raw PCM data




*PCM: Pulse Code Modulation            Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   7
Demo
Playback
 – Player
 – AudioOut




              Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   8
Basic method




               Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   9
AudioRecorder class
 Records audio data from input source to storage
 – Recording format
    • WAV, AMR
 Event
  – IAudioRecorderEventListener
    •   OnAudioRecorderPaused
    •   OnAudioRecorderStarted
    •   OnAudioRecorderStopped
    •   OnAudioRecorderClosed
    •   OnAudioRecorderCanceled
    •   …
 "RECORDING" privilege is needed
                              Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   10
Using the AudioRecorder class
 Create AudioRecorder instance
 __pAR = new AudioRecorder;
 __pAR->Construct(*pListener);
              // IAudioRecorderEventListener

 Recording
 __pAR->CreateAudioFile( __path, true);
 __pAR->SetFormat(AUDIORECORDING_FORMAT_WAVE);
 __pAR->Record();
 Stop recording & close
 __pAR->Stop();
 …
 void EventListener::OnAudioRecorderStopped( result r)
 {
     __pAR->Close();
 }
                                  Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   11
Player class
 Can play audio & video
 – Multiple audio playback is supported(max 10)
    • Only 1 compressed audio files
 – Can play audio/video by streaming
    • Streaming Protocol: Real-Time Streaming Protocol
      (RTSP)
 Event
 – IPlayerEventListener
    •   OnPlayerBuffering,   OnPlayerInterrupted
    •   OnPlayerEndOfClip,   OnPlayerErrorOccurred
    •   OnPlayerOpened,      OnPlayerReleased
    •   OnPlayerSeekCompleted
                                    Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   12
Using the Player class
 Create Player instance
 __pPlayer = new Player;
 __pPlayer->Construct(*pListener);
                            // IPlayerEventListener

 Load file & play
 result r = __pPlayer->OpenFile(__path);
 if (IsFailed(r)) return;
 __pPlayer->Play();

 Stop
 __pPlayer->Stop();
 __pPlayer->Close();




                                 Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   13
Complex method




                 Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   14
Record PCM data
 AudioIn class
 – Record raw uncompressed PCM data from
   microphone
 – Double buffering is possible
 Event Listener
 – IAudioInEventListener
    • OnAudioInBufferIsFilled
    • OnAudioInInterrupted
    • OnAudioInReleased


                           Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   15
Using the AudioIn class
 Create AudioIn instance
 __pAudioIn = new AudioIn();
 __pAudioIn->Construct(*__pListener);
 __pAudioIn-> Prepare (AUDIO_INPUT_DEVICE_MIC,
 AUDIO_TYPE_PCM_U8, AUDIO_CHANNEL_TYPE_STEREO,8000);

 Feed buffers and start recording
 __pAudioIn->AddBuffer(__pByteBuffer1);
 __pAudioIn->Start();

 Feed next buffers
 void Listener::OnAudioInBufferIsFilled
 ( Osp::Base::ByteBuffer* pData)
 { // save result.
     pData->Clear();
     __pAudioIn->AddBuffer(pData);
                              Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   16
Play PCM data
 AudioOut
 – Play raw uncompressed PCM data
 – Double buffering is possible
 Event listener
 – IAudioOutEventListener
    • OnAudioOutBufferEndReached
    • OnAudioOutInterrupted
    • OnAudioOutReleased



                        Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   17
Using the AudioOut class
 Create AudioOut instance
 __pAO = new AudioOut();
 __pAO->Construct(*pListener);// IAudioOutEventListener
 __pAO->Prepare(AUDIO_TYPE_PCM_S16_LE,
             AUDIO_CHANNEL_TYPE_MONO, SAMPLERATE);
 __pOutBuffer = new ByteBuffer();
 __pOutBuffer->Construct(BUFSIZE);

 Feed PCM data
 // Fill buffer
 __pAO->WriteBuffer(*__pOutBuffer);

 Play sound
 __pAO->Start();



                                 Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   18
Using the AudioOut class ctd.
 Process events
 void EventListener::OnAudioOutBufferEndReached
 (Osp::Media::AudioOut &src)
 { //Feed Next PCM data }

 Stop sound
 __pAO->Stop();   //or Reset()




                                 Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   19
Double buffering in AudioIn
Step 1. Initialize AudioIn                                                      Recording
                             AudioIn Device
                                                                                application




                                 Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   20
Double buffering in AudioIn
Step 1. Initialize AudioIn                                                      Recording
                             AudioIn Device
Step 2. Add two buffers                                                         application




                                     Buffer1

                                     Buffer2




                                 Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   21
Double buffering in AudioIn
Step 1. Initialize AudioIn                                                      Recording
                             AudioIn Device
Step 2. Add two buffers                                                         application

Step 3. Start recording
Step 4. Buffer1 is filled

                                     Buffer1

                                     Buffer2




                                 Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   22
Double buffering in AudioIn
Step 1. Initialize AudioIn                                                      Recording
                             AudioIn Device
Step 2. Add two buffers                                                         application

Step 3. Start recording             Event:
                                 Buffer is filled
Step 4. Buffer1 is filled
Step 5. Event is fired               Buffer1
Buffer2 is used by AudioIn
                                     Buffer2




                                 Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   23
Double buffering in AudioIn
Step 1. Initialize AudioIn                                                         Recording
                                AudioIn Device
Step 2. Add two buffers                                                            application

Step 3. Start recording
Step 4. Buffer1 is filled
Step 5. Event is fired                  Buffer1
Buffer2 is used by AudioIn
                                        Buffer2
Step 6. App. reads Buffer1
and AudioIn writes to Buffer2




                                    Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   24
Double buffering in AudioIn
Step 1. Initialize AudioIn                                                         Recording
                                AudioIn Device
Step 2. Add two buffers                                                            application

Step 3. Start recording                Event:
                                    Buffer is filled
Step 4. Buffer1 is filled
Step 5. Event is fired                  Buffer1
Buffer2 is used by AudioIn
                                        Buffer2
Step 6. App. reads Buffer1
and AudioIn writes to Buffer2
Step 7. Event is fired
AudioIn switches to Buffer1




                                    Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   25
Double buffering in AudioIn
Step 1. Initialize AudioIn                                                         Recording
                                AudioIn Device
Step 2. Add two buffers                                                            application

Step 3. Start recording
Step 4. Buffer1 is filled
Step 5. Event is fired                  Buffer1
Buffer2 is used by AudioIn
                                        Buffer2
Step 6. App. reads Buffer1
and AudioIn writes to Buffer2
Step 7. Event is fired
AudioIn switches to Buffer1
Step 8. Read Buffer2


                                    Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   26
Double buffering in AudioOut
Step 1. Initialize AudioOut                                                        Player
                              AudioOut Device
                                                                                 application




                                  Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   27
Double buffering in AudioOut
Step 1. Initialize AudioOut                                                        Player
                              AudioOut Device
                                                                                 application
Step 2. Add two buffers




                                      Buffer1

                                      Buffer2




                                  Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   28
Double buffering in AudioOut
Step 1. Initialize AudioOut                                                        Player
                              AudioOut Device
                                                                                 application
Step 2. Add two buffers
Step 3. Start playback
Step 4. Buffer1 is read

                                      Buffer1

                                      Buffer2




                                  Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   29
Double buffering in AudioOut
Step 1. Initialize AudioOut                                                        Player
                              AudioOut Device
                                                                                 application
Step 2. Add two buffers
                                         Event:
Step 3. Start playback
                                 Buffer end is reached
Step 4. Buffer1 is read
Step 5. Event is fired                Buffer1
Buffer2 is used by AudioOut
                                      Buffer2




                                  Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   30
Double buffering in AudioOut
Step 1. Initialize AudioOut                                                           Player
                                 AudioOut Device
                                                                                    application
Step 2. Add two buffers
Step 3. Start playback
Step 4. Buffer1 is read
Step 5. Event is fired                   Buffer1
Buffer2 is used by AudioOut
                                         Buffer2
Step 6. AudioOut reads Buffer2
and app writes to Buffer1




                                     Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   31
Double buffering in AudioOut
Step 1. Initialize AudioOut                                                           Player
                                 AudioOut Device
                                                                                    application
Step 2. Add two buffers
                                            Event:
Step 3. Start playback
                                    Buffer end is reached
Step 4. Buffer1 is read
Step 5. Event is fired                   Buffer1
Buffer2 is used by AudioOut
                                         Buffer2
Step 6. AudioOut reads Buffer2
and app writes to Buffer1
Step 7. Event is fired
AudioOut switches to Buffer1




                                     Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   32
Double buffering in AudioOut
Step 1. Initialize AudioOut                                                           Player
                                 AudioOut Device
                                                                                    application
Step 2. Add two buffers
Step 3. Start playback
Step 4. Buffer1 is read
Step 5. Event is fired                   Buffer1
Buffer2 is used by AudioOut
                                         Buffer2
Step 6. AudioOut reads Buffer2
and app writes to Buffer1
Step 7. Event is fired
AudioOut switches to Buffer1
Step 8. Write to Buffer2


                                     Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   33
Simple Mixing




                Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   34
Why mixing?
 Play many sounds simultaneously
 – Limited number of player instances
 – System resource limited
 Performance issue
 – Consume less computing power
 Flexibility
 – Finer control of PCM data is possible



                          Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   35
.wav file
                                  Field                             Field
                                  Offset      Field Name            Size
                                 (bytes)                           (bytes)
 Important .wav header               0
                                                 Chunk ID             4
                                     4
                                                                                      RIFFHeader
 fields                              8
                                               Chuck Size
                                                  Format
                                                                      4
                                                                      4
                                    12
                                             Subchunk1 ID             4
                                    16
Field            Value                      Subchunk1 Size            4
                                    20
                                              Audio Format            2
Channels         mono/stereo        22
                                             Num Channels             2
Sample rate      8/22/44.1Khz       24
                                              Sample Rate             4
                                                                                      WavFormatInfo
                                    28
                                                Byte Rate             4
Bit per sample   8bit /16bit        32
                                               Block Align            2
Size             raw data size      34
                                            Bits Per Sample           2
                                    36
                                             Subchunk2 ID             4
PCM data         raw data           40                                                ChnkHeader
                                            Subchunk2 Size            4
                                    44




                                                                      Subchunk2size
                                                    Data




                                 Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   36
Loading .wav file
 Open file
  File f;
  f.Construct(/*File Path*/, String(L"r"));

 Read header
  f.Read(&__RIFFHeader, sizeof(RIFFHEader));
  f.Read(&__WavFormat, sizeof(WavFormatInfo));

 Read PCM data
  ChnkHeader tmp;
  f.Read((void *)&tmp, sizeof(ChnkHeader));
  __pData = new Osp::Base::ByteBuffer;
  __pData->Construct(tmp.size);
  f.Read(*__pData);
  __pData->Rewind();


                              Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   37
Simple mixing
 Step 1: Create buffers
 __pTmpBuf = new ByteBuffer();
 __pTmpBuf->Construct(size*4);       //int type


 Step 2: Add the buffers
 int* pTmp =
     static_cast<int *> (__pTmpBuf->GetPointer());
 short* pData1 =
     static_cast<short *> (__pData1->GetPointer());
 short* pData2 =
     static_cast<short *> (__pData2->GetPointer());
 for (int i = 0; i < size; i++)
         pTmp[i] = pData1[i] + pData2[i] ;




                                 Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   38
Simple mixing
 Step 3: Clip the buffers
 short * pOut =
     static_cast<short *> (__pOutBuf->GetPointer());

 for( int i=0;i<size;i++)
 {
     if (pTmp[i] >= SHRT_MAX)       pOut[i] = SHRT_MAX*;
     else if ( pTmp[i] <= SHRT_MIN) pOut[i] = SHRT_MIN*;
     else                           pOut[i] = pTmp[i];
 }
        *SHRT_MAX, SHRT_MIN: maximum and minimum values of short type


 Step 4: Write the buffer to AudioOut
 __pAO->WriteBuffer(*__pOutBuf);



                                    Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   39
Image & Video management
•   Image
•   Video
•   Streaming




                 Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   40
Image
 Can encode, decode, convert images
 Supported pixel format
 – RGB565/ARGB8888/R8G8B8A8
 Decoding
 – BMP, GIF, PNG, TIFF, WBMP
 Encoding
 – BMP, JPEG, PNG
 "IMAGE" privilege is needed

                          Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   41
Image class decode/encode
 Load image
 Bitmap* LoadBitmapN(const String& name)
 {
     Bitmap* pBitmap = null;
     Image* pImage = new Image();
     pImage->Construct();
     pBitmap = pImage->DecodeN(name,
            BITMAP_PIXEL_FORMAT_ARGB8888);
     delete pImage;
     return pBitmap;
 }

 Save image
 pImage->EncodeToFile(*pBitmap,
                  IMG_FORMAT_PNG, name, true);


                              Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   42
Video playing
 Can play video using Player class
 – Using OverlayPanel to display video
 Code snippet
 – Create player
    pPlayer = new Player();
    pPlayer->Construct(*pListener, &bufferInfo);
 – Open file
    pPlayer->OpenFile(String(L"/Res/badaBI.mp4"));
 – Play/stop/pause/close
    pPlayer->Play(); //Pause() or Stop() or Close()




                              Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   43
OverlayPanel
 Primarily used for the playback of camera
 previews or video
 – Foreground panel
    • Overlay graphics and controls
 – Background buffer
    • Support H/W accelerated rendering
                      Foreground panel

    Input buffer
                      Masking color




                   Background buffer   Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   44
OverlayPanel ctd.
 Create a panel and get bufferInfo
 pPanel= new OverlayPanel();
 pPanel->Construct(rect);
 AddControl(*pPanel);
 pPanel->GetBackgroundBufferInfo(bufferInfo);

 Use the bufferInfo in the Player class
 pPlayer->Construct(*pListener, &bufferInfo);




                              Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   45
Streaming
 Can play audio/video streaming content
 – Supported protocol : RTSP
 – Supported video codecs : MPEG4, H.263,
   H.264
 – Supported audio codecs : AAC, HE-AAC,
   Enhanced-AAC+, AMR-NB
 pPlayer->OpenURL(
        String(L“RTSP://IP address/content"));




                              Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   46
Demo
MediaPlayer
 – Video Playback
 – OverlayPanel




                    Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   47
Tips for Performance
 Preffered PCM format to reduce internal
 operations
 Field            Values
 Channels         stereo
 Sample rate      44.1Khz
 Bit per sample   16bit


 Double buffering to reduce latency
 Sound mixing can reduce internal resources and
 event processing


                            Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   48
Tips for Programming
Handled automatically by platform
Headset   • Plug and unplug events are not fired
          • Platform changes the sound path automatically
Incoming • Player, AudioIn, and AudioOut are stopped by
call      platform
          • Resuming should be done by application
                 (Osp::App::Application::OnForeground)




                                Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   49
Tips for Programming
Handled by application
Silent mode • Event is not fired
             • Application should check silent mode
                  (Osp::System::SettingInfo )
Side volume • Application should deal with volume controls
key          • Application handles key event
                  (Osp::Ui::IKeyEventListener)
Foreground/ • Player consumes too much power
background • On background, stop playing audio and
             video



                                Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   50
Summary




          Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   51
What we have learned
 Basic way to record and play audio
  – AudioRecorder / Player classes
 Playing and recording PCM data
  – AudioIn / AudioOut classes
  – Wav file format / Simple mixing
 Image and Video management
  – Image encode/decode
  – OverlayPanel for video
  – Streaming both audio and video

                          Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   52
Find out more
 Tutorial
 – bada Tutorial.Media.pdf
 Samples
 – MediaPlayer
 – VoiceRecorder




                         Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved.   53
Dive into
                                    http://www.goprodiver.com
   Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 54

Contenu connexe

En vedette

자바스터디 3 3
자바스터디 3 3자바스터디 3 3
자바스터디 3 3jangpd007
 
Bhagat bosc2010 bio_catalogue
Bhagat bosc2010 bio_catalogueBhagat bosc2010 bio_catalogue
Bhagat bosc2010 bio_catalogueBOSC 2010
 
Expert growers level
Expert growers levelExpert growers level
Expert growers levelJean Smith
 
אשנב לחטב סופי
אשנב לחטב   סופיאשנב לחטב   סופי
אשנב לחטב סופיbenny
 
P P T The Dilemma Of Death
P P T The  Dilemma Of  DeathP P T The  Dilemma Of  Death
P P T The Dilemma Of DeathLarry Langley
 
Academic Honesty at Oxford College of Emory University
Academic Honesty at Oxford College of Emory UniversityAcademic Honesty at Oxford College of Emory University
Academic Honesty at Oxford College of Emory Universityoxfordcollegelibrary
 
Chapter 4: Renewable Generation and Security of Supply
Chapter 4: Renewable Generation and Security of SupplyChapter 4: Renewable Generation and Security of Supply
Chapter 4: Renewable Generation and Security of SupplyElectricidad Verde
 
How Stupid Can We Get
How Stupid Can We GetHow Stupid Can We Get
How Stupid Can We Get555123
 
Chap010 creating customer dialogue
Chap010 creating customer dialogueChap010 creating customer dialogue
Chap010 creating customer dialogueHee Young Shin
 
Instructional ppt
Instructional pptInstructional ppt
Instructional pptJessWalker1
 
Презентация препарата bio-rost.com
Презентация препарата bio-rost.comПрезентация препарата bio-rost.com
Презентация препарата bio-rost.comАльберт Коррч
 

En vedette (20)

자바스터디 3 3
자바스터디 3 3자바스터디 3 3
자바스터디 3 3
 
My Home Town
My Home TownMy Home Town
My Home Town
 
Misery
MiseryMisery
Misery
 
Bhagat bosc2010 bio_catalogue
Bhagat bosc2010 bio_catalogueBhagat bosc2010 bio_catalogue
Bhagat bosc2010 bio_catalogue
 
Expert growers level
Expert growers levelExpert growers level
Expert growers level
 
אשנב לחטב סופי
אשנב לחטב   סופיאשנב לחטב   סופי
אשנב לחטב סופי
 
Small Business Profits Tune-Up
Small Business Profits Tune-UpSmall Business Profits Tune-Up
Small Business Profits Tune-Up
 
P P T The Dilemma Of Death
P P T The  Dilemma Of  DeathP P T The  Dilemma Of  Death
P P T The Dilemma Of Death
 
Academic Honesty at Oxford College of Emory University
Academic Honesty at Oxford College of Emory UniversityAcademic Honesty at Oxford College of Emory University
Academic Honesty at Oxford College of Emory University
 
Chapter 4: Renewable Generation and Security of Supply
Chapter 4: Renewable Generation and Security of SupplyChapter 4: Renewable Generation and Security of Supply
Chapter 4: Renewable Generation and Security of Supply
 
Learninggk
LearninggkLearninggk
Learninggk
 
Marketing transformation management
Marketing transformation managementMarketing transformation management
Marketing transformation management
 
How Stupid Can We Get
How Stupid Can We GetHow Stupid Can We Get
How Stupid Can We Get
 
Unagi
UnagiUnagi
Unagi
 
Chap010 creating customer dialogue
Chap010 creating customer dialogueChap010 creating customer dialogue
Chap010 creating customer dialogue
 
Job
JobJob
Job
 
3 Stories
3 Stories3 Stories
3 Stories
 
Instructional ppt
Instructional pptInstructional ppt
Instructional ppt
 
Презентация препарата bio-rost.com
Презентация препарата bio-rost.comПрезентация препарата bio-rost.com
Презентация препарата bio-rost.com
 
Hey, soul sister
Hey, soul sisterHey, soul sister
Hey, soul sister
 

Similaire à sounds in bada

Ig2 task 1 work sheet 2
Ig2 task 1 work sheet 2Ig2 task 1 work sheet 2
Ig2 task 1 work sheet 2JoeBrannigan
 
Ig2 task 1 work sheet
Ig2 task 1 work sheetIg2 task 1 work sheet
Ig2 task 1 work sheetGladeatorkid
 
Brienna hick sound recording glossary
Brienna hick sound recording glossaryBrienna hick sound recording glossary
Brienna hick sound recording glossarysoulsama
 
Digital recording
Digital recordingDigital recording
Digital recordinggps2012
 
Ig2 task 1 work sheet 2
Ig2 task 1 work sheet 2Ig2 task 1 work sheet 2
Ig2 task 1 work sheet 2JoeBrannigan
 
Audio and video streaming
Audio and video streamingAudio and video streaming
Audio and video streamingRohan Bhatkar
 
Ig2 task 1 work sheet
Ig2 task 1 work sheetIg2 task 1 work sheet
Ig2 task 1 work sheetNeilRogero
 
Anthony bowes IG2 task 1
Anthony bowes  IG2 task 1 Anthony bowes  IG2 task 1
Anthony bowes IG2 task 1 bowes96123
 
Sound recording glossary improved
Sound recording glossary improvedSound recording glossary improved
Sound recording glossary improvedItsLiamOven
 
Extract the Audio from Video by using python
Extract the Audio from Video by using pythonExtract the Audio from Video by using python
Extract the Audio from Video by using pythonIRJET Journal
 
Streaming Overview Final.ppt
Streaming Overview Final.pptStreaming Overview Final.ppt
Streaming Overview Final.pptVideoguy
 
Streaming Overview Final.ppt
Streaming Overview Final.pptStreaming Overview Final.ppt
Streaming Overview Final.pptVideoguy
 
Streaming Overview Final.ppt
Streaming Overview Final.pptStreaming Overview Final.ppt
Streaming Overview Final.pptVideoguy
 

Similaire à sounds in bada (20)

Ig2 task 1 work sheet
Ig2 task 1 work sheetIg2 task 1 work sheet
Ig2 task 1 work sheet
 
Introduction to Podcasting
Introduction to PodcastingIntroduction to Podcasting
Introduction to Podcasting
 
Ig2task1worksheet
Ig2task1worksheetIg2task1worksheet
Ig2task1worksheet
 
IG2 Task 1
IG2 Task 1 IG2 Task 1
IG2 Task 1
 
Ig2 task 1 work sheet 2
Ig2 task 1 work sheet 2Ig2 task 1 work sheet 2
Ig2 task 1 work sheet 2
 
Ig2 task 1 work sheet
Ig2 task 1 work sheetIg2 task 1 work sheet
Ig2 task 1 work sheet
 
Brienna hick sound recording glossary
Brienna hick sound recording glossaryBrienna hick sound recording glossary
Brienna hick sound recording glossary
 
Digital recording
Digital recordingDigital recording
Digital recording
 
It 2 x-2hdmi-datasheet
It 2 x-2hdmi-datasheetIt 2 x-2hdmi-datasheet
It 2 x-2hdmi-datasheet
 
Ig2 task 1 work sheet 2
Ig2 task 1 work sheet 2Ig2 task 1 work sheet 2
Ig2 task 1 work sheet 2
 
Audio and video streaming
Audio and video streamingAudio and video streaming
Audio and video streaming
 
Ig2 task 1 work sheet
Ig2 task 1 work sheetIg2 task 1 work sheet
Ig2 task 1 work sheet
 
Anthony bowes IG2 task 1
Anthony bowes  IG2 task 1 Anthony bowes  IG2 task 1
Anthony bowes IG2 task 1
 
Sound recording glossary improved
Sound recording glossary improvedSound recording glossary improved
Sound recording glossary improved
 
Ig2 task 1 work sheet
Ig2 task 1 work sheetIg2 task 1 work sheet
Ig2 task 1 work sheet
 
Extract the Audio from Video by using python
Extract the Audio from Video by using pythonExtract the Audio from Video by using python
Extract the Audio from Video by using python
 
Digital recording final
Digital recording   finalDigital recording   final
Digital recording final
 
Streaming Overview Final.ppt
Streaming Overview Final.pptStreaming Overview Final.ppt
Streaming Overview Final.ppt
 
Streaming Overview Final.ppt
Streaming Overview Final.pptStreaming Overview Final.ppt
Streaming Overview Final.ppt
 
Streaming Overview Final.ppt
Streaming Overview Final.pptStreaming Overview Final.ppt
Streaming Overview Final.ppt
 

Plus de Samsung

Making Your Apps More Sociable
Making Your Apps More SociableMaking Your Apps More Sociable
Making Your Apps More SociableSamsung
 
introduction of application certification
introduction of application certificationintroduction of application certification
introduction of application certificationSamsung
 
samsung apps for bada
samsung apps for badasamsung apps for bada
samsung apps for badaSamsung
 
managing your content
managing your contentmanaging your content
managing your contentSamsung
 
embedding web browser in your app
embedding web browser in your appembedding web browser in your app
embedding web browser in your appSamsung
 
advanced ui large custom list with search
advanced ui large custom list with searchadvanced ui large custom list with search
advanced ui large custom list with searchSamsung
 
bada basics fundamentals & ui
bada basics fundamentals & uibada basics fundamentals & ui
bada basics fundamentals & uiSamsung
 

Plus de Samsung (7)

Making Your Apps More Sociable
Making Your Apps More SociableMaking Your Apps More Sociable
Making Your Apps More Sociable
 
introduction of application certification
introduction of application certificationintroduction of application certification
introduction of application certification
 
samsung apps for bada
samsung apps for badasamsung apps for bada
samsung apps for bada
 
managing your content
managing your contentmanaging your content
managing your content
 
embedding web browser in your app
embedding web browser in your appembedding web browser in your app
embedding web browser in your app
 
advanced ui large custom list with search
advanced ui large custom list with searchadvanced ui large custom list with search
advanced ui large custom list with search
 
bada basics fundamentals & ui
bada basics fundamentals & uibada basics fundamentals & ui
bada basics fundamentals & ui
 

Dernier

Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 

Dernier (20)

Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 

sounds in bada

  • 1. Sounds in bada Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 1
  • 2. Contents Introduction Common Sound Classes – AudioRecorder/Player – AudioIn/AudioOut Simple Mixing Media Management – Image – Video – Streaming Summary *This material is based on bada SDK 1.0.0b3 Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 2
  • 3. Media Introduction Audio/ video/ image processing functions Key features Audio Video Image • Playback • Playback • Load • Record • Record • Save • Streaming • Streaming • Format conversion • PCM processing • Camera capture • Camera preview Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 3
  • 4. Supported Formats Type Format Encode Decode Streaming* Video H.263, MPEG-4 (.3gp, mp4) O O O H.264 (.3gp, mp4) O O VC-1 (.wmv, .asf) O Audio PCM (.wav) O O AMR-NB (.amr, .3ga, .m4a) O O O AAC, AAC+, EAAC+ O O (.aac, .3ga, .m4a) MIDI (.mid, .spm, .imy, .mmf, .xmf) O MP3 (.mp3), WMA ( .wma, .asf) O Image JPEG, PNG, BMP O O GIF, TIFF, WBMP O *Streaming Protocol: RTSP Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 4
  • 5. Header & Library Header file: – #include <FMedia.h> Library – Simulator: FMedia – Target: FOsp Privilege groups – RECORDING – IMAGE – CAMERA Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 5
  • 6. Common Sound Classes Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 6
  • 7. Audio Recorder & Player Basic method Complex method :General purpose :Direct access to device Recording Recording – AudioRecorder : Records – AudioIn : Read raw PCM audio data from input data from input srouce source to storage Playing Playing – Player : Open audio file – AudioOut : Play sound with and play raw PCM data *PCM: Pulse Code Modulation Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 7
  • 8. Demo Playback – Player – AudioOut Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 8
  • 9. Basic method Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 9
  • 10. AudioRecorder class Records audio data from input source to storage – Recording format • WAV, AMR Event – IAudioRecorderEventListener • OnAudioRecorderPaused • OnAudioRecorderStarted • OnAudioRecorderStopped • OnAudioRecorderClosed • OnAudioRecorderCanceled • … "RECORDING" privilege is needed Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 10
  • 11. Using the AudioRecorder class Create AudioRecorder instance __pAR = new AudioRecorder; __pAR->Construct(*pListener); // IAudioRecorderEventListener Recording __pAR->CreateAudioFile( __path, true); __pAR->SetFormat(AUDIORECORDING_FORMAT_WAVE); __pAR->Record(); Stop recording & close __pAR->Stop(); … void EventListener::OnAudioRecorderStopped( result r) { __pAR->Close(); } Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 11
  • 12. Player class Can play audio & video – Multiple audio playback is supported(max 10) • Only 1 compressed audio files – Can play audio/video by streaming • Streaming Protocol: Real-Time Streaming Protocol (RTSP) Event – IPlayerEventListener • OnPlayerBuffering, OnPlayerInterrupted • OnPlayerEndOfClip, OnPlayerErrorOccurred • OnPlayerOpened, OnPlayerReleased • OnPlayerSeekCompleted Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 12
  • 13. Using the Player class Create Player instance __pPlayer = new Player; __pPlayer->Construct(*pListener); // IPlayerEventListener Load file & play result r = __pPlayer->OpenFile(__path); if (IsFailed(r)) return; __pPlayer->Play(); Stop __pPlayer->Stop(); __pPlayer->Close(); Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 13
  • 14. Complex method Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 14
  • 15. Record PCM data AudioIn class – Record raw uncompressed PCM data from microphone – Double buffering is possible Event Listener – IAudioInEventListener • OnAudioInBufferIsFilled • OnAudioInInterrupted • OnAudioInReleased Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 15
  • 16. Using the AudioIn class Create AudioIn instance __pAudioIn = new AudioIn(); __pAudioIn->Construct(*__pListener); __pAudioIn-> Prepare (AUDIO_INPUT_DEVICE_MIC, AUDIO_TYPE_PCM_U8, AUDIO_CHANNEL_TYPE_STEREO,8000); Feed buffers and start recording __pAudioIn->AddBuffer(__pByteBuffer1); __pAudioIn->Start(); Feed next buffers void Listener::OnAudioInBufferIsFilled ( Osp::Base::ByteBuffer* pData) { // save result. pData->Clear(); __pAudioIn->AddBuffer(pData); Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 16
  • 17. Play PCM data AudioOut – Play raw uncompressed PCM data – Double buffering is possible Event listener – IAudioOutEventListener • OnAudioOutBufferEndReached • OnAudioOutInterrupted • OnAudioOutReleased Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 17
  • 18. Using the AudioOut class Create AudioOut instance __pAO = new AudioOut(); __pAO->Construct(*pListener);// IAudioOutEventListener __pAO->Prepare(AUDIO_TYPE_PCM_S16_LE, AUDIO_CHANNEL_TYPE_MONO, SAMPLERATE); __pOutBuffer = new ByteBuffer(); __pOutBuffer->Construct(BUFSIZE); Feed PCM data // Fill buffer __pAO->WriteBuffer(*__pOutBuffer); Play sound __pAO->Start(); Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 18
  • 19. Using the AudioOut class ctd. Process events void EventListener::OnAudioOutBufferEndReached (Osp::Media::AudioOut &src) { //Feed Next PCM data } Stop sound __pAO->Stop(); //or Reset() Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 19
  • 20. Double buffering in AudioIn Step 1. Initialize AudioIn Recording AudioIn Device application Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 20
  • 21. Double buffering in AudioIn Step 1. Initialize AudioIn Recording AudioIn Device Step 2. Add two buffers application Buffer1 Buffer2 Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 21
  • 22. Double buffering in AudioIn Step 1. Initialize AudioIn Recording AudioIn Device Step 2. Add two buffers application Step 3. Start recording Step 4. Buffer1 is filled Buffer1 Buffer2 Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 22
  • 23. Double buffering in AudioIn Step 1. Initialize AudioIn Recording AudioIn Device Step 2. Add two buffers application Step 3. Start recording Event: Buffer is filled Step 4. Buffer1 is filled Step 5. Event is fired Buffer1 Buffer2 is used by AudioIn Buffer2 Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 23
  • 24. Double buffering in AudioIn Step 1. Initialize AudioIn Recording AudioIn Device Step 2. Add two buffers application Step 3. Start recording Step 4. Buffer1 is filled Step 5. Event is fired Buffer1 Buffer2 is used by AudioIn Buffer2 Step 6. App. reads Buffer1 and AudioIn writes to Buffer2 Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 24
  • 25. Double buffering in AudioIn Step 1. Initialize AudioIn Recording AudioIn Device Step 2. Add two buffers application Step 3. Start recording Event: Buffer is filled Step 4. Buffer1 is filled Step 5. Event is fired Buffer1 Buffer2 is used by AudioIn Buffer2 Step 6. App. reads Buffer1 and AudioIn writes to Buffer2 Step 7. Event is fired AudioIn switches to Buffer1 Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 25
  • 26. Double buffering in AudioIn Step 1. Initialize AudioIn Recording AudioIn Device Step 2. Add two buffers application Step 3. Start recording Step 4. Buffer1 is filled Step 5. Event is fired Buffer1 Buffer2 is used by AudioIn Buffer2 Step 6. App. reads Buffer1 and AudioIn writes to Buffer2 Step 7. Event is fired AudioIn switches to Buffer1 Step 8. Read Buffer2 Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 26
  • 27. Double buffering in AudioOut Step 1. Initialize AudioOut Player AudioOut Device application Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 27
  • 28. Double buffering in AudioOut Step 1. Initialize AudioOut Player AudioOut Device application Step 2. Add two buffers Buffer1 Buffer2 Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 28
  • 29. Double buffering in AudioOut Step 1. Initialize AudioOut Player AudioOut Device application Step 2. Add two buffers Step 3. Start playback Step 4. Buffer1 is read Buffer1 Buffer2 Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 29
  • 30. Double buffering in AudioOut Step 1. Initialize AudioOut Player AudioOut Device application Step 2. Add two buffers Event: Step 3. Start playback Buffer end is reached Step 4. Buffer1 is read Step 5. Event is fired Buffer1 Buffer2 is used by AudioOut Buffer2 Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 30
  • 31. Double buffering in AudioOut Step 1. Initialize AudioOut Player AudioOut Device application Step 2. Add two buffers Step 3. Start playback Step 4. Buffer1 is read Step 5. Event is fired Buffer1 Buffer2 is used by AudioOut Buffer2 Step 6. AudioOut reads Buffer2 and app writes to Buffer1 Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 31
  • 32. Double buffering in AudioOut Step 1. Initialize AudioOut Player AudioOut Device application Step 2. Add two buffers Event: Step 3. Start playback Buffer end is reached Step 4. Buffer1 is read Step 5. Event is fired Buffer1 Buffer2 is used by AudioOut Buffer2 Step 6. AudioOut reads Buffer2 and app writes to Buffer1 Step 7. Event is fired AudioOut switches to Buffer1 Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 32
  • 33. Double buffering in AudioOut Step 1. Initialize AudioOut Player AudioOut Device application Step 2. Add two buffers Step 3. Start playback Step 4. Buffer1 is read Step 5. Event is fired Buffer1 Buffer2 is used by AudioOut Buffer2 Step 6. AudioOut reads Buffer2 and app writes to Buffer1 Step 7. Event is fired AudioOut switches to Buffer1 Step 8. Write to Buffer2 Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 33
  • 34. Simple Mixing Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 34
  • 35. Why mixing? Play many sounds simultaneously – Limited number of player instances – System resource limited Performance issue – Consume less computing power Flexibility – Finer control of PCM data is possible Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 35
  • 36. .wav file Field Field Offset Field Name Size (bytes) (bytes) Important .wav header 0 Chunk ID 4 4 RIFFHeader fields 8 Chuck Size Format 4 4 12 Subchunk1 ID 4 16 Field Value Subchunk1 Size 4 20 Audio Format 2 Channels mono/stereo 22 Num Channels 2 Sample rate 8/22/44.1Khz 24 Sample Rate 4 WavFormatInfo 28 Byte Rate 4 Bit per sample 8bit /16bit 32 Block Align 2 Size raw data size 34 Bits Per Sample 2 36 Subchunk2 ID 4 PCM data raw data 40 ChnkHeader Subchunk2 Size 4 44 Subchunk2size Data Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 36
  • 37. Loading .wav file Open file File f; f.Construct(/*File Path*/, String(L"r")); Read header f.Read(&__RIFFHeader, sizeof(RIFFHEader)); f.Read(&__WavFormat, sizeof(WavFormatInfo)); Read PCM data ChnkHeader tmp; f.Read((void *)&tmp, sizeof(ChnkHeader)); __pData = new Osp::Base::ByteBuffer; __pData->Construct(tmp.size); f.Read(*__pData); __pData->Rewind(); Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 37
  • 38. Simple mixing Step 1: Create buffers __pTmpBuf = new ByteBuffer(); __pTmpBuf->Construct(size*4); //int type Step 2: Add the buffers int* pTmp = static_cast<int *> (__pTmpBuf->GetPointer()); short* pData1 = static_cast<short *> (__pData1->GetPointer()); short* pData2 = static_cast<short *> (__pData2->GetPointer()); for (int i = 0; i < size; i++) pTmp[i] = pData1[i] + pData2[i] ; Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 38
  • 39. Simple mixing Step 3: Clip the buffers short * pOut = static_cast<short *> (__pOutBuf->GetPointer()); for( int i=0;i<size;i++) { if (pTmp[i] >= SHRT_MAX) pOut[i] = SHRT_MAX*; else if ( pTmp[i] <= SHRT_MIN) pOut[i] = SHRT_MIN*; else pOut[i] = pTmp[i]; } *SHRT_MAX, SHRT_MIN: maximum and minimum values of short type Step 4: Write the buffer to AudioOut __pAO->WriteBuffer(*__pOutBuf); Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 39
  • 40. Image & Video management • Image • Video • Streaming Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 40
  • 41. Image Can encode, decode, convert images Supported pixel format – RGB565/ARGB8888/R8G8B8A8 Decoding – BMP, GIF, PNG, TIFF, WBMP Encoding – BMP, JPEG, PNG "IMAGE" privilege is needed Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 41
  • 42. Image class decode/encode Load image Bitmap* LoadBitmapN(const String& name) { Bitmap* pBitmap = null; Image* pImage = new Image(); pImage->Construct(); pBitmap = pImage->DecodeN(name, BITMAP_PIXEL_FORMAT_ARGB8888); delete pImage; return pBitmap; } Save image pImage->EncodeToFile(*pBitmap, IMG_FORMAT_PNG, name, true); Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 42
  • 43. Video playing Can play video using Player class – Using OverlayPanel to display video Code snippet – Create player pPlayer = new Player(); pPlayer->Construct(*pListener, &bufferInfo); – Open file pPlayer->OpenFile(String(L"/Res/badaBI.mp4")); – Play/stop/pause/close pPlayer->Play(); //Pause() or Stop() or Close() Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 43
  • 44. OverlayPanel Primarily used for the playback of camera previews or video – Foreground panel • Overlay graphics and controls – Background buffer • Support H/W accelerated rendering Foreground panel Input buffer Masking color Background buffer Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 44
  • 45. OverlayPanel ctd. Create a panel and get bufferInfo pPanel= new OverlayPanel(); pPanel->Construct(rect); AddControl(*pPanel); pPanel->GetBackgroundBufferInfo(bufferInfo); Use the bufferInfo in the Player class pPlayer->Construct(*pListener, &bufferInfo); Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 45
  • 46. Streaming Can play audio/video streaming content – Supported protocol : RTSP – Supported video codecs : MPEG4, H.263, H.264 – Supported audio codecs : AAC, HE-AAC, Enhanced-AAC+, AMR-NB pPlayer->OpenURL( String(L“RTSP://IP address/content")); Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 46
  • 47. Demo MediaPlayer – Video Playback – OverlayPanel Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 47
  • 48. Tips for Performance Preffered PCM format to reduce internal operations Field Values Channels stereo Sample rate 44.1Khz Bit per sample 16bit Double buffering to reduce latency Sound mixing can reduce internal resources and event processing Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 48
  • 49. Tips for Programming Handled automatically by platform Headset • Plug and unplug events are not fired • Platform changes the sound path automatically Incoming • Player, AudioIn, and AudioOut are stopped by call platform • Resuming should be done by application (Osp::App::Application::OnForeground) Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 49
  • 50. Tips for Programming Handled by application Silent mode • Event is not fired • Application should check silent mode (Osp::System::SettingInfo ) Side volume • Application should deal with volume controls key • Application handles key event (Osp::Ui::IKeyEventListener) Foreground/ • Player consumes too much power background • On background, stop playing audio and video Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 50
  • 51. Summary Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 51
  • 52. What we have learned Basic way to record and play audio – AudioRecorder / Player classes Playing and recording PCM data – AudioIn / AudioOut classes – Wav file format / Simple mixing Image and Video management – Image encode/decode – OverlayPanel for video – Streaming both audio and video Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 52
  • 53. Find out more Tutorial – bada Tutorial.Media.pdf Samples – MediaPlayer – VoiceRecorder Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 53
  • 54. Dive into http://www.goprodiver.com Copyright © 2010 Samsung Electronics Co., Ltd. All rights reserved. 54