280 likes | 310 Views
Audio Processing. Yongchang, Kai, Justin, Rama. Audio Processing. System Analysis. Input: Raw WAV Format Data Output: Normalized Wave Signal. System Analysis (continued) Step 1: Preprocessing. Input: Raw WAV Format Data Output: Preprocessed Wave Data Set Sample Rate: 8k Hz
E N D
Audio Processing Yongchang, Kai, Justin, Rama
System Analysis • Input: Raw WAV Format Data • Output: Normalized Wave Signal
System Analysis (continued)Step 1: Preprocessing • Input: Raw WAV Format Data • Output: Preprocessed Wave Data Set • Sample Rate: 8k Hz • Channels: 1 = Mono • Bits Per Sample: 8 bits
System Analysis (continued)Step 2: Audio Processing • Input: Preprocessed Wave Data Set • Output: Single Wave Signal
Raw WAV Format Data Preprocessed Wave Data Preprocessing Channel Audio Processing Preprocessed Wave Data Each Signal to Be Played
System Analysis (continued) • Preprocessed input data: • Illegal format – thrown away • Legal format – converted to the suitable format • Preprocessing is very important • Save the cost of the satellite • Time • Space • Decrease risk: illegal data can make the satellite system crash
System Analysis (continued) • Preprocessed input data: • Illegal format – thrown away • Legal format – converted to the suitable format • Preprocessing is very important • Save the cost of the satellite • Time • Space • Decrease risk: illegal data can make the satellite system crash
Offset Field Size Comment The “RIFF” Chunk 0 ChunkID 4 "RIFF" 4 ChunckSize 4 36 + SubChunk2Size The “fmt” Sub-chunk 8 Format 4 "WAVE" Unit: Byte( s ) The “data” Sub-chunk Basic Wave File Format
Offset Field Size Comment 12 Subchunk1ID 4 "fmt " 16 Subchunk1Size 4 16 for PCM The “RIFF” Chunk 20 AudioFormat 2 PCM = 1 22 NumChannels 2 Mono = 1, Stereo = 2, etc The “fmt” Sub-chunk 24 SampleRate 4 8k, 44.1k, etc 28 ByteRate 4 SR*NC*BPS/8 The “data” Sub-chunk 32 BlockAlign 2 NC * BPS / 8 34 BitsPerSample 2 8 bits = 8, 16 bits = 16, etc Basic Wave File Format • SR = SampleRate, NC = NumChannels • BPS = BitsPerSample
Offset Field Size Comment The “RIFF” Chunk 36 Subchunk2ID 4 “data" 40 Subchunk2Size 4 NumSamples * NumChannels * BitsPerSample/8 The “fmt” Sub-chunk 44 Data * The actual sound data The “data” Sub-chunk Basic Wave File Format
Preprocessed Wave Format Normalized Data
Raw Data Legal Format ? No Report Error Yes Preprocessing Preprocessed Data System Designfor Preprocessor
System Designfor Preprocessor • int LoadRawFile( char * apchRawFileName ); • Load the raw format wave file and check it. • pchRawFileName: File name of the raw wave file. • Return value: • 0 – Successfully • Negative value – There exists error • int ConvertTo( char * apchNewFormatFile ); • Convert the legal wave data to the preprocessed format • pchNewFormatFile: File name of the preprocessed data. • Return value: • 0 – Successfully • Negative value – There exists error
File ID Yes Is playing ? Ignore and Return No Initializing Finally process and Return Yes playing Over? No Play System Designfor AudioProcessor ( Concept )
OnTimer File ID playing Over? Yes No Yes Is playing ? Ignore Send One Byte to DAC No Initializing Hardware and Software Return Start Timer Stop Timer and Return Return System Designfor AudioProcessor ( Implement )
System Designfor AudioProcessor • int play_audio( char * apchFileID ); • Initialize hardware and software and be ready for playing. • apchFileID: Wave file to be played. • Return value: • 0 – To be played. • -1 – Request is ignored • void write_data_onto_DAC( void ); • To be called when TimerB18000 interrupt occurs • void initialise_hw( void ); • Initialize hardware for playing sound
System Designfor AudioProcessor ( About DAC ) DAC12_1CTL = DAC12IR + DAC12AMP_5 + DAC12ENC; • DAC12IR: • In DAC12_xCTL, DAC12 Control Register. Bit 8. • DAC12 input range. This bit sets the reference input and voltage output range. • 0 DAC12 full-scale output = 3x reference voltage • 1 DAC12 full-scale output = 1x reference voltage • DAC12AMPx: • DAC12ENC:
System Designfor AudioProcessor ( About DAC ) DAC12_1CTL = DAC12IR + DAC12AMP_5 + DAC12ENC; • DAC12IR: • DAC12AMPx: • In DAC12_xCTL, DAC12 Control Register. Bits : 7-5 • DAC12 amplifier setting. These bits select settling time vs. current consumption for the DAC12 input and output amplifiers. • DAC12ENC:
System Designfor AudioProcessor ( About DAC ) DAC12_1CTL = DAC12IR + DAC12AMP_5 + DAC12ENC; • DAC12IR: • DAC12AMPx: • DAC12ENC: • In DAC12_xCTL, DAC12 Control Register. Bit 1. • DAC12 enable conversion. This bit enables the DAC12 module when DAC12LSELx > 0. when DAC12LSELx = 0, DAC12ENC is ignored. • 0 DAC12 disabled • 1 DAC12 enabled
Testing • Preprocessor passed testing • AudioProcessor passed testing
Demo of Preprocessor II The output file is a *.h file, so that we can directly include this file and get the data.
Status • Problem: • There is no file system API, so real audio files can’t be processed. • Solution: • Now we use a char array to simulate an audio file. ( less flexibility ) • Maybe resolving packets directly will be more elegant.
Future • Wait for the file system APIs? ( or solve it ourselves ) • Re-design audio processing APIs? • Flexible ( not only play 8k Hz audio ) • Extensible ( multimedia processing ) • Available ( non-stop service ) • Reliable ( not a toy ) • Maintainable