Home

Audio File Resolution Resizer - OHM ECCE

image

Contents

1. 26 Header Include Start Header Include End Add Custom Events only in the appropriate block Code added in other places will be removed by wxDev C Event Table Start BEGIN EVENT TABLE Audio Resolution ChangerFrm wxFrame Manual Code Start Manual Code End EVT CLOSE Audio Resolution ChangerFrm OnClose EVT ACTIVATE Audio Resolution ChangerFrm Audio Resolution _ ChangerFrmActivate EVT TEXT ID ADDMAXABSERROR Audio Resolution ChangerFrm WxE ditlUpdated EVT TEXT ID MAXABSERROR Audio Resolution ChangerFrm WxEdit lUpdated EVT BUTTON ID NEXT Audio Resolution ChangerFrm WxNextClick EVT BUTTON ID BACK Audio Resolution ChangerFrm WxBackClick EVT BUTTON ID GOTOSAMPLE Audio Resolution ChangerFrm Wxgot osampleClick EVT CHOICE ID BITSIZE Audio Resolution ChangerFrm bitsizeS elected EVT BUTTON ID CLEAR Audio Resolution ChangerFrm WxclearCli ck EVT_TEXT ID AVEABSERROR Audio Resolution ChangerFrm WxEdit lUpdated EVT TEXT ID TOTALABSERROR Audio Resolution ChangerFrm WxEd itlUpdated EVT TEXT ID SAMPLES Audio Resolution ChangerFrm WxEditlUpd 2T ated EVT BUTTON ID SAVE Audio Resolution ChangerFrm WxButton1Cl ick0 EVT TEXT ID TEXTBOX2 Audio Resolution ChangerFrm textboxUp dated EVT BUTTON ID OPENBUTTON Audio Resolution ChangerFrm WxBut tonlClick EN
2. 33 for int b 0 b lt Subchunk2Size BitsPerSample 8 b Routine for absolute errors AbsoluteError b OriginalData b ResizedData b gets the absolute error TotalAbsoluteError TotalAbsoluteError AbsoluteError b gets the total absolute error if AbsoluteError b gt MaxAbsoluteError finds the maximum absolute error MaxAbsoluteError AbsoluteError b AddressMaxAbsoluteError b float a 8 0 AverageAbsoluteError TotalAbsoluteError Subchunk2Size BitsPerSample ail get average error display data char buffer 16 char bufferl 16 char buffer2 16 char buffer3 16 char buffer4 16 itoa numberofsamples buffer 10 Samples gt SetValue buffer snprintf bufferl 16 Sf AverageAbsoluteError AveAbsError gt SetValue bufferl snprintf buffer2 16 sf TotalAbsoluteError TotalAbsError gt SetValue buffer2 itoa MaxAbsoluteError buffer3 10 itoa AddressMaxAbsoluteError buffer4 10 MaxAbsError gt SetValue buffer3 AddMaxAbsError gt SetValue buffer4 WxButton1Click0 e void Audio Resolution ChangerFrm WxButton1C1ick0 wxCommandEvent amp eve
3. void Audio Resolution ChangerFrm WxEditlUpdated wxCommandEvent amp event samplenumberUpdated ies 35 gotosample Clicked Xy void Audio Resolution ChangerFrm Wx nt amp event gotosampleClick wxCommandEve wxString temp4 samplenum gt GetValue sampnum atoi temp4 c_str if sampnum gt numberofsamples 1 sampnum lt 0 sampleerror gt ShowModal else char buffer 17 char buffer8 17 short templ OriginalData sampnum short temp2 ResizedData sampnum itoa templ buffer7 10 originalsample gt SetValue buffer7 itoa temp2 buffer8 10 resizedsample gt SetValue buffers void Audio Resolution ChangerFrm Wx event BackClick wxCommandEvent amp char bufferl1l0 20 wxString temp4 samplenum gt GetValue int sampnum atoi temp4 c_str sampnum sampnum 1 itoa sampnum bufferl0 10 samplenum gt SetValue bufferl0 if sampnum gt numberofsamples 1 sampnum lt 0 sampleerror gt ShowModal else char buffer 17 char buffer8 17 36 short templ OriginalData sampnum short temp2 ResizedData sampnum itoa templ buffer7 10 originalsample gt SetValue buffer7 itoa temp2 buffer8 10 r
4. ifdef BORLANDC __ pragma hdrstop endif ifndef WX _PRECOMP include lt wx wx h gt else finclude lt wx wxprec h gt endif class audio resolution changerfrmapp public wxApp public bool OnInit int OnExit endif 25 A2 1 3 audio file resolution resizerfrm cpp AA eS a SS ee SS a Se See E aa eee 1 file Audio Resolution ChangerFrm cpp author Jan Michael Abuzo Jose Arguelles Francis Cruz Created 1 1 2002 10 40 22 AM section DESCRIPTION LAA Audio Resolution ChangerFrmFrm class implementation AI include audio file resolution resizerfrm h include lt wx filename h gt finclude lt stdio h gt include lt stdlib h gt include lt iostream gt include lt math h gt include lt string gt finclude lt sstream gt using namespace std Butters etc char ChunkID 4 Format 4 Subchunk11D 4 Subchunk21D 4 int ChunkSize Subchunk1Size SampleRate ByteRate Subchunk2Size short AudioFormat NumChannels BlockAlign BitsPerSample short AbsoluteError float AverageAbsoluteError oat TotalAbsoluteError int BitSize int AddressMaxAbsoluteError int MaxAbsoluteError short OriginalData short ResizedData int numberofsamples sampnum Do not add custom headers between Header Include Start and Header Include End wxDev C designer will remove them
5. gt SetBackgroundColour wxSystemSettings Ge ID_ADDMAXABSERROR AddMaxAbsError UU wxT 0 wxDefaultValidator new wxTextCtrl this wxPoint 310 wxT AddMaxAbsError 203 wxSize 37 AddMaxAbsError gt Enable false AddMaxAbsError UR_APPWORKSPACE tColour wxSYS COLO MaxAbsError new wxTextCtrl this ID MAXABSERROR wxT wxPoint 129 203 wxSize 114 18 0 wxDefaultValidator wxT MaxAbsError MaxAbsError gt Enable false MaxAbsError gt SetBackgroundColour wxSystemSettings GetColour wxSYS_ COLO UR_APPWORKSPACE WxStaticText5 new wxStaticText this ID WXSTATICTEXTS5 wxT Max Absolute Error wxPoint 2 203 wxDefaultSize 0 wxT WxStaticText5 Next new wxButton this ID NEXT wxT Next wxPoint 246 274 wxSize 47 23 0 wxDefaultValidator wxT Next Next gt SetFont wxFont 12 wxSWISS wxNORMAL wxNORMAL false back new wxButton this ID BACK wxT Back wxPoint 187 274 wxSize 47 23 0 wxDefaultValidator wxT back back gt SetFont wxFont 12 wxSWISS wxNORMAL wxNORMAL false gotosample new wxButton this ID GOTOSAMPLE wxT Go to Sample wxPoint 187 231 wxSize 107 39 0 wxDefaultValidator wxT gotosample gotosample gt SetFont wxFont 12 wxSWISS wxNORMAL wxNORMAL false s
6. OriginalData new short Subchunk2Size BitsPerSample 8 fread OriginalData BitsPerSample 8 Subchunk2Size BitsPerSample 8 fhandle Reading raw audio data fclose fhandle Fh Fh Fh t 3 3 Data Manipulation Data manipulations are performed on the audio data itself using resizing as well as statistical data involving the results 12 3 3 1 Resizing Algorithm Depth conversion is done by decreasing the 16 bit resolution of the sample into a lesser x sized bit resolution determined by the user and is then used to reproduce a 16 bit long sample The resizing is done by dividing the sample by 2 to get the lesser depth sample and then multiplied again by 2 to recover a 16 bit long sample The procedure is the same as using the bit operator gt gt and lt lt which effectively shifts the bits to the right and left accordingly at a given amount producing division and multiplications by powers of two The errors that are obtained would come from the bits that are truncated and they are the 16 x bits starting from the least significant bit The following code performs the resizing for int b 0 b lt Subchunk2Size BitsPerSample 8 b ResizedData b OriginalData b gt gt 16 BitSize lt lt 16 B itSize 3 3 2 Statistical Data Collection 3 3 2 1 Absolute Error Absolute error is obtained by subtracting the Original
7. A1 2 7 Saving the Converted Audio File The output audio file or its destination can be selected by clickng Save on the GUI A file browser will appear and the user can select wav files to overwrite them or create a new wav file by typing a name on the File Name tab A1 2 8 Exiting the Program The program can be closed by clicking the X button at the upper right hand corner of the GUI 20 Appendix 2 Source Code A2 Source Code A2 1 Source Files A2 1 1 audio_file_resolution_resizerfrm h PP ASS eRe Si Ra SA SS Z file Audio Resolution ChangerFrm h author Jan Michael Abuzo Jose Arguelles Francis Cruz Created 1 1 2002 10 40 22 AM section DESCRIPTION Ee Audio Resolution ChangerFrm class declaration IA la ua fifndef Audio Resolution ChangerFrmFRM H define Audio Resolution ChangerFrmFRM H ifdef BORLANDC __ pragma hdrstop endif ifndef WK PRECOMP include lt wx wx h gt include lt wx frame h gt else finclude lt wx wxprec h gt endif Do not add custom headers between Header Include Start and Header Include End wxDev Ct designer will remove them Add custom headers after the block Header Include Start finclude lt wx msgdlg h gt 21 include lt wx filedlg h gt include lt wx choice h gt include lt wx stattext h gt include lt wx textctrl h gt
8. After all data processes have been done the program is now ready to write the converted data sotred in ResizedData into another WAV audio file fhandle is again set as the output stream to be written in binary mode on a file specificied by the user After the fwrite command is done in the same way the fread was done in order to create a replica of the header of the original audio WAV file ResizedData is the only new data introduced into the file which contains the converted values of OriginalData fhandle fopen temp2 wb fwrite ChunkID 1 4 fhandle 14 fwrite amp ChunkSize 4 1 fhandle fwrite Format 1 4 fhandle fwrite Subchunk1ID 1 4 fhandle fwrite amp Subchunk1Size 4 1 fhandle fwrite amp AudioFormat 2 1 fhandle fwrite amp NumChannels 2 1 fhandle fwrite amp SampleRate 4 1 fhandle fwrite amp ByteRate 4 1 fhandle fwrite amp BlockAlign 2 1 fhandle fwrite amp BitsPerSample 2 1 fhandle fwrite amp Subchunk21D 1 4 fhandle fwrite amp Subchunk2Size 4 1 fhandle fwrite ResizedData BitsPerSample 8 Subchunk2Size BitsPerSample 8 fhandle fclose fhandle 15 4 User Interface The User Interface of the Audio File Resizer program was developed using wxDev C It allowed the use of widgets such as buttons and dialogs
9. include lt wx button h gt Header Include End Dialog Style Start undef Audio Resolution ChangerFrm STYLE define Audio Resolution ChangerFrm STYLE wxCAPTION wXSYSTEM MENU wxMINIMIZE BOX wxMAXIMIZE BOX wxCLOSE BOX Dialog Style End class Audio Resolution ChangerFrm public wxFrame private DECLARE EVENT TABLE public Audio Resolution ChangerFrm wxWindow parent wxWindowID id 1 const wxString amp title wxT Audio Resolution Changer const wxPointg pos wxDefaultPosition const wxSize amp size wxDefaultSize long style Audio Resolution ChangerFrm STYLE virtual Audio Resolution ChangerFrm void WxButton1Click wxCommandEvent event void Audio Resolution ChangerFrmActivate wxActivateEvent amp event void WxMemolUpdated wxCommandEvent amp event void textboxUpdated wxCommandEvent amp event void WxButton1C1lick0 wxCommandEvent amp event void SaveClick wxCommandEvent event void StartClick wxCommandEvent amp event void WxEditlUpdated wxCommandEvent amp event void Audio Resolution ChangerFrm WxgotosampleClick wxCommandEve nt amp event void Audio Resolution ChangerFrm WxclearClick wxCommandEvent event void samplenumberUpdated wxCommandEvent amp event void WxButton1Click1 wxCommandEvent amp event void bitsizeSelected wxCommandEvent event void WxComboBox1Selected wxC
10. WAVE PCM audio files as its original data file The program will not be able to increase the bit depth higher than the original but it should be able to reduce it to any number of bits from 1 to 15 bits per sample The only parts of the fmt subchunk that may vary is the subchunk size and the number of channels the rest must remain the same It is also important to note that the indexing will not display properly for certain multi channel audio files 2 4 Implementation Summary The project will be using devC to create a program that will allow WAVE files of the specific format to be opened and the raw data to be extracted from the file Afterwards the program will downsize the sample to the specified number of bits then upsize it once again to its original size of 16 bits and save a new file with the modified bits Then the program will proceed to calculating for the statistical data that is needed for the project 10 3 Discussion of Program 3 1 Declaration and Initialization of Variables The first step when the program is run is to initialize the variables it will use The variables declared are used to 1 store information on the WAV audio data to be read 2 store audio data upon conversion 3 store statistical data after comparing the original data and the converted data 1 The information to be stored in a WAV audio file to be read are separated into three variable types the 1 byte wide character type and the 2 byte
11. any error IDs then you need to change your old form code that define control IDs defines may replace enum names Try copy and pasting form header files enum a numeric the below with these enum are based on the value for the block in your old GUI Enum Control ID Start D WXSTATICTEXT6 D_ADDMAXABSERROR D_MAXABSERROR D WXSTATICTEXT5 D NEXT 49 D BACK 48 D GOTOSAMPLE D SAMPNUM 46 D WXSTATICTEXT4 D BITSIZE 38 D CLEAR 37 D AVEABSERROR D WXSTATICTEXT8 D WXSTATICTEXT7 D SAMPLE 27 D RESIZEDSAMPLE D ORIGINALSAMPLE 4 DIA IZ Sly 50 1 40 Sy 29 28 24 23 D_TOTALABSERROR D_SAMPLES 17 D WXSTATICTEXT2 D WXSTATICTEXT1 D TEXTBOX1 8 ID SAVE 7 ID TEXTBOX2 4 ID OPENBUTTON 1 GUI Enum Cont ID 24 D WXSTATICTEXT3 19 12 D I 9 A rol ID End DUMMY VALUE don t remove this value unless you have other enum values Lop private void OnClose wxCloseEvent amp event void CreateGUIControls endif A2 1 2 audio_file_resolution_resizerapp h Name Audio Resolution ChangerApp h Author Jan Michael Abuzo Jose Arguelles Francis Cruz Created 1 1 2002 10 40 22 AM Description ifndef AUDIO RESOLUTION CHANGERFRMApp h define AUDIO RESOLUTION CHANGERFRMApp h
12. of the CD A1 2 2 Loading an Input Audio File The input file to be resized can be selected by clicking the Open button on the Graphical User Interface A file browser will appear and you will be allowed to select the chosen WAV file to be converted Only files with wav extensions are selectable After selecting the desired WAV file click Open on the browser to select the file The directory of the chosen file will now show on the GUI A1 2 3 Selecting a Bit Size The GUI will then ask for a bit size for the conversion Any number between 1 15 is valid The directory of the output file will now be displayed on the GUI A1 2 4 Statistical Data Display The program will automatically display on the GUI the statistical data of the converted data after providing the bit size Changing the bit size will refresh the values for the statistical data 19 A1 2 5 Selecting Specific Samples The user is free to select and display the values of the samples both of the original and resized by providing a sample on the space beside it and clicking on Go to Sample This will show both decimal values for the original and resized samples The user is also able to browse adjacent samples by clicking next or back to see their values The samples are refreshed only through the Go to Sample button A1 2 6 Clearing the Data All data the file being converted and statistical data can be cleared by clicking the Clear Field button
13. that can be easily programmed The program s GUI allows the user to open a wav file and can later save the resized file After opening a valid 16 bit file the user can begin down converting from 1 bit to 15 bits E Audio File Resizer Wem Destination Directory The statistical differences used is absolute error These are automatically generated after choosing the bit size to down convert to These values compare the original data with those of the down converted and resized data 16 ER Audio File Resizer 167387 ja b Clear Fields 255 207352 42718392 000000 Go to Sample Destination Directory The user can navigate through the data samples by entering the sample number in the field indicated The user is also not allowed to enter values beyond the number of samples numbering of samples start at zero The decimal values of the original and the resized data are compared here The user also has can opt to save the new wav file Finally the user has the option to clear all fields in the program ER Audio File Resizer Go to Sample gt a Weieng em Destination Directory 17 This program makes use of 8 files for its source codes audio file resolution resizer dev audio file resolution resizer layout audio file resolution resizerfrm cpp audio file resolution resizerFrm cpp audio file resolution resizerfrm h audio file resolution resizerFrm wxform audio file resoluti
14. 2 0 wxDefaultValidator wxT textbox2 textbox2 gt Enable false OpenButton new wxButton this ID OPENBUTTON wxT Open wxPoint 1 23 wxSize 75 25 O wxDefaultValidator wxT OpenButton SetTitle wxT Audio File Resizer SetIcon wxNullicon SetSize 8 8 372 387 Center GUI Items Creation End void Audio Resolution ChangerFrm OnClose wxCloseEvent amp event Destroy 31 WxButtonlClick e void Audio Resolution ChangerFrm WxButton1C1ick wxCommandEvent event if OQpenFile gt ShowModal wxID_OK wxString temp OpenFile gt GetPath textbox1 gt SetValue temp Read the wave file FILE fhandle fopen temp rb fread ChunkI1D 1 4 fhandle fread read read read FH FH FH FH fread amp Bit fread amp ChunkSize 4 1 fhandle fread Format 1 4 fhandl e Subchunkl ID 1 4 amp Subchunki fhandle Size 4 1 fhandle amp AudioFormat 2 1 fhandle amp NumChanne read amp SampleRate 4 1 fread 8ByteRate 1s 2 1 fhandle fhandle andle 4 1 1 fread 8 BlockAlign 2 1 tsPerSamp fhandle e 2 1 fhandl e fread Subchunk21D 1 4 fhandl fread amp Subchunk2Size 4 1 d e fhandle OriginalData new
15. Audio File Resolution Resizer Jan Michael Abuzo Jose Roman D Arguelles Francis Ray R Cruz Audio File Resolution Resizer A Project by Jan Michael Abuzo Jose Roman D Arguelles Francis Ray R Cruz Submitted to Luisito L Agustin Instructor ELC 152 In Partial Fulfillment of the Requirements for the Course ELC 152 Signal Processing Department of Electronics Computer and Communications Engineering School of Science and Engineering Loyola Schools Ateneo de Manila University Quezon City Philippines October 2010 Abstract The purpose of this project is to analyze audio audio files By manipulating and analyzing the audio digital sample s bit depth it will be possible to gain statistical data from modifying sample data The statistical data will provide for a measure of the converted data in comparison to the original data The data is related to understanding the properties of compressing data It will also determine what bit depths are capable of producing reasonable audio quality Table of Contents A AA aa 5 LL Adios 5 EN DEE SORE EE 5 LA LIS WAV FUL a ia 5 ALE Pulse Code Modo ir poroto ion adi 7 EE 7 JR EE 8 A A Eeer 8 2 Project OVerVieW onor AT A A AS aa 9 LOUIS a io id 9 2 2 Significance OF the Projet a a 9 2S SCOPES ANE imitations AI AO 9 2 4 Implementation Summary A amwe amwamini wina 9 Sy DISCUSSION OF PLOT A A AS TOS 11 3 1 Declaration and Initialization of Vanables 11 3 2 Fil RE
16. D EVENT TABLE Event Table End Audio Resolution ChangerFrm Audio Resolution ChangerFrm wx Window parent wxWindowID id const wxString amp title const wxPoint amp position const wxSizeg size long style wxFrame parent id title position size style CreateGUIControls Audio Resolution ChangerFrm Audio Resolution ChangerFrm void Audio Resolution ChangerFrm CreateGUIControls Do not add custom code between GUI Items Creation Start and GUI Items Creation End wxDev C designer will remove them Add the custom code before or after the blocks GUI Items Cr ation Start sampleerror new wxMessageDialog this wxT Sample number invalid check number of samples above Sample number starts at 0 wxT Error OpenFile new wxFileDialog this wxT Choose a wav file wxT wxT wxT wav wxOPEN bitratecheck new wxMessageDialog this wxT Sampling rate should be 16 bits choose a different file wxT Error bitmessage new wxMessageDialog this wxT Open a valid 16 bit file first wxT Error SaveFile new wxFileDialog this wxT Choose a file wxT wxT wxT wav wxSAVE WxStaticText6 new wxStaticText this ID WXSTATICTEXT6 wxT At sample wxPoint 255 203 wxDefaultSize 0 wxT WxStaticText6 28 18
17. Data b by ResizedData b for all samples in the audio file The following code provides for the the absolute error for int b 0 b lt Subchunk2Size BitsPerSample 8 b AbsoluteError b OriginalData b ResizedData b gt 3 3 2 2 Maximum Absolute Error As the absolute error is being calculated the maximum absolute error is checked by setting the variable MaxAbsoluteError equal to AbsoluteError b whenever AbsoluteError b is greater than MaxAbsoluteError The following code provides for the maximum absolute error if AbsoluteError b gt MaxAbsoluteError 13 MaxAbsoluteError AbsoluteError b AddressMaxAbsoluteError b The address of the specific sample is also appended to find which sample gives the maximum absolute error 3 3 2 3 Total Absolute Error The total absolute error is obtained by summing each errors unto each other as the program solves for each error The following code provides for the maximum absolute error TotalAbsoluteError TotalAbsoluteError AbsoluteError b 3 3 2 4 Average Absolute Error The average absolute error is obtained can be obtained after all absolute errors are sovled by dividing the total absolute error by the number of samples which is given by Subchunk2Size BitsPerSample 8 The following code provides for the average absolute error AverageAbsoluteError TotalAbsoluteError Subchunk2Size BitsPerSample 8 3 4 File writing
18. N AS aida 12 3 3 Data MAPA a 12 E RESIZING ALSOP ai 13 3 3 2 Statistical Data Coll O EE 13 33 21 Absolute Oi 13 3 3 2 2 Maxzum Absolute ET 13 3 3 2 3 Total Absolute EE s 14 3 3 2 4 Averag A DSO EE 14 EE A 14 4o User ut ea o ad o al 16 Appendix User s ET AI EE 19 AE Software RE 19 EE 19 KEE UE A A A 19 A1 2 1 Using e 19 A1 2 2 Loading an Input Audio Pla id 19 A1 2 3 Selecting an Output Audio File and Bit Stze ee eeeeseeeteeeeeeteeeeeeneeeeees 19 ALZA Statistical Data 6p lay eegener i n 19 A1 2 5 Sele ting Specific e EE 20 A1 2 6 Exiting the Progr Me nania a as dias 20 Appendi 2 SOUCE EEN 21 AZ SOURCE AE 21 A2 1 1 audio file resolution EIER eren due A 21 A2 1 2 audio file resolution tesizerapp ivan dida dan 25 A2 1 3 audio file resolution resizerfrm CpPP wwwwwswmwemwemaweamwmmnmwma 26 A2 1 4 audio file resolution restzerapp pp 37 A2 1 5 audio file resolution EE ee 38 A2 1 6 audio file resolution resizerapp DP 38 Ee dee ees 40 1 Introduction 1 1 Audio Files It is common knowledge that computers use digital signals to process data Yet audio signals are analog in nature So for a computer to create audio files that can be read by it the audio signals go through a processing method that represents the analog audio signal in digital form for the computer to understand 1 1 1 RIFF Format The Resource Interchange File Format RIFF is a type of multimedia file format that is common
19. a Figure 1 Standard WAVE File Format The Chunk ID as mentioned above is the four characters that is used to identify the file format in this case the four characters are R I F and F ChunkSize determines the number of the rest of the remaining chunks The Format chunk contains the characters W A V and E to identify that the file is indeed a WAVE file The next chunk the Subchunk ID contains the the characters f m and t This describes the data of the sound format SubchunkSize determines the size of the rest of the subchunks In this case the Subchunksize is 16 since that is what is required for PCM AudioFormat is set to one for PCM by using different values it indicates a type of compression NumChannels is for the number of channels of the audio file When it is set to one it is mono if it is set to two then it is stereo SampleRate determines the number of samples the file will take per second The ByteRate is the sample rate multiplied by the number of channels and the bits per sample divided by 8 BlockAlign is the number of channels multiplied by the bits per sample divided by 8 BitsPerSample is the number of bits that are used for each sample For this program the number of bits per sample will be 16 Another common term fot this is the audio bit depth For the project this is the part that the program will generally alter The next part is the Subchunk2ID this contains the characters d a t and a For Subchunk2Size it contains t
20. amplenum new wxTextCtrl this ID SAMPNUM wxT wxPoint 83 230 wxSize 101 19 wxTE_RIGHT wxDefaultValidator wxT samplenum WxStaticText4 new wxStaticText this ID WXSTATICTEXT4 wxT Bi 89 Size to Convert to wxPoint 1 wxDefaultSize 0 wxT WxStaticText4 wxArrayString arrayStringFor bitsize arrayStringFor bitsize Add wxT 1 arrayStringFor bitsize Add wxT 2 arrayStringFor bitsize Add wxT 3 arrayStringFor bitsize Add wxT 4 arrayStringFor bitsize Add wxT 5 arrayStringFor bitsize Add wxT 6 29 arrayStringFor bitsize Add wxT 7 arrayStringFor bitsize Add wxT 8 arrayStringFor bitsize Add wxT 9 arrayStringFor bitsize Add wxT 10 arrayStringFor bitsize Add wxT 11 arrayStringFor bitsize Add wxT 12 7 arrayStringFor bitsize Add wxT 13 y5 arrayStringFor bitsize Add wxT 14 A arrayStringFor bitsize Add wxT 15 bitsize new wxChoice this ID BITSIZE wxPoint 110 87 wxSize 64 21 arrayStringFor esoo Ak wxDefaultValidator wxT bitsize bitsize gt SetSelection 1 clear new wxButton this ID CLEAR wxT Clear Fields wxPoint 253 134 wxSize 107 39 0 wxDefaultValidator wxT clear clear gt SetFont wxFont 12 wxSWISS wxNORMAL wxNORMAL false Av
21. eAbsError new wxTextCtrl this ID AVEABSERROR wxT wxPoint 129 158 wxSize 114 18 0 wxDefaultValidator wxT AveAbsError AveAbsError gt Enable false AveAbsError gt SetBackgroundColour wxSystemSettings GetColour wxSYS_ COLO UR_APPWORKSPACE WxStaticText8 new wxStaticText this ID WXSTATICTEXT8 wxT Resized Sample wxPoint 1 279 wxDefaultSize 0 wxT WxStaticText8 WxStaticText7 new wxStaticText this ID WXSTATICTEXT7 wxT Original Sample wxPoint 1 257 wxDefaultSize 0 wxT WxStaticText7 Sample new wxStaticText this ID SAMPLE wxT Sample wxPoint 1 235 wxDefaultSize 0 wxT Sample resizedsample new wxTextCtrl this ID RESIZEDSAMPLE wxT wxPoint 83 277 wxSize 101 19 wxTE_RIGHT wxDefaultValidator wxT resizedsample resizedsample gt Enable false originalsample new wxTextCtrl this ID ORIGINALSAMPLE wxT wxPoint 83 255 wxSize 101 19 wxTE RIGHT wxDefaultValidator wxT originalsample originalsample gt Enable false TotalAbsError new wxTextCtrl this ID TOTALABSERROR wxT wxPoint 129 181 wxSize 114 18 O wxDefaultValidator wxT TotalAbsError TotalAbsError gt Enable false 30 TotalAbsError gt SetBackgroundColour wxSys UR_APPWORKSPACE
22. esizedsample gt SetValue buffers void Audio Resolution _ChangerFrm WxNextClick wxCommandEvent event char bufferl1l0 20 wxString temp4 samplenum gt GetValue int sampnum atoi temp4 c_str sampnum sampnumt1 itoa sampnum buffer10 10 samplenum gt SetValue bufferl0 1f sampnum gt numberofsamples 1 sampnum lt 0 sampleerror gt ShowModal else char buffer 17 char buffer8 17 short templ OriginalData sampnum short temp2 ResizedData sampnum itoa templ buffer7 10 originalsample gt SetValue buffer7 itoa temp2 buffer8 10 resizedsample gt SetValue buffer8 A2 1 4 audio file resolution _resizerapp cpp Name Audio Resolution ChangerApp cpp Author Jan Michael Abuzo Jose Arguelles Francis Cruz Created 1 1 2002 10 40 22 AM Description 37 include Audio Resolution ChangerApp h include Audio Resolution ChangerFrm h IMPLEMENT APP Audio Resolution ChangerFrmApp bool Audio Resolution ChangerFrmApp OnInit Audio Resolution ChangerFrm frame new Audio Resolution ChangerFrm NULL SetTopWindow frame frame gt Show return true int A
23. he number of bytes there are in the data Finally the Data contains the actual audio data For this program the WAVE files that are being used will be in PCM format 1 1 1 2 Pulse Code Modulation For the program the WAVE files will be using Linear Pulse Code Modulation LPCM This is basically Pulse Code modulation that uses linear quantization to normalize the modulated signal Since audio signals are analog PCM is a valid choice to represent the audio signal digitally By sending a serial train of equal sized pulses this allows the analog signal to be represented as a digital signal Below is an image displaying the the PCM representation of an analog signal 15 14 13 12 11 10 wo NU RUANG O m Figure 2 PCM Representation It is important to note this since the program that will be discussed will be manipulating the values of the PCM encoded samples 1 2 Data Statistics For the program statistics will be needed to observe the differences in the data that was collected and manipulated For this program part of the analysis will require to get the error and the average error of the manipulated data compared to the original data 1 2 1 Error The error is the difference between the original value and the experimental data in question In the case of the program once the samples are manipulated the error between the original value of the sample and the resized value of the samp
24. le will be compared 1 2 2 Averages A basic statistical equation is adding all the data values and by diving it by the sample size to get the average or the mean By adding all the error values taken and dividing the total number of error values in the program the average error values obtained With the average values it will give a general picture of the amount of error that can be expected for a certain bit resolution variance 2 Project Overview 2 1 Objectives The purpose of this project is to create a program that can modify the audio resolution of a 16 bit PCM WAVE file The program will reduce the sample data to a selected number of bits then resize it back to the sample s original audio bit depth Afterwards the error for each sample is obtained The average error and the maximum error are then obtained from the collected modified samples 2 2 Significance of the Project The significance of the project is to help in understanding the the effect of reducing the bit depth of an audio sample from its original size From the statistical data it can be seen by how much an audio sample is affected by the downsizing and then upsizing of the sample From this it can be seen if the reduction significantly affected the audio file The program is related to compression as well since it concerns reducing the size of the samples then returning it back to its original bit depth 2 3 Scope and Limitations The project will only use 16 bit
25. ly allocated memory equal to the number of samples in the data chunk 11 3 2 File Rreading File reading involves a repetitive call to the function fread in order to store all data of the WAV file to be converted The process begins first by declaring fhandle as the stream of audio data by using fopen on the audio file in read binary mode Then it follows a series of fread commands that is ordered accordingly to the RIFF format for WAV files After reading Subchunk2Size and BitsPerSample the storage for the data OriginalData is then allocated memory of size Subchunk2Size BitsPerSample 8 which is equal to the number of samples in the data chunk Other arrays such The last fread command is done for the audio samples and is stored to a memory location pointed by OriginalData The file stream is then closed The following code performs the file reading process FILE fhandle fopen temp rb fread ChunkID 1 4 fhandle fread amp ChunkSize 4 1 fhandle fread Format 1 4 fhandle fread Subchunk11D 1 4 fhandle fread amp Subchunk1Size 4 1 fhandle fread amp AudioFormat 2 1 fhandle read amp NumChannels 2 1 fhandle h read amp SampleRate 4 1 fhandle read amp ByteRate 4 1 fhandle read amp BlockAlign 2 1 fhandle fread amp BitsPerSample 2 1 fhandle fread Subchunk21D 1 4 fhandle fread amp Subchunk2Size 4 1 fhandle
26. ly used by different multimedia functions The structure is similar to that of the Electronic Arts IFF files For an RIFF file the basic building blocks are called chunks In a chunk there are three parts that need to be considered The first part is the chunk identification it is usually a four character code that determines the type of file Once the program reads this it will identify the file and begin reading the different types of chunks that the format needs The second parts is the chunk size this part determines the size of the chunk data The third part is the chunk data This part contains binary data of a fixed or variable size For the RIFF format there are two other parts of the data structure that need to be considered The Header ID and the Data Size the first one gives the name of the list while the second one lists the chunks There are also different types of RIFF forms that follow an RIFF framework In the case of the program the form that the group shall use will be the Waveform Audio Format 1 1 1 1 WAV Files The Waveform Audio File Format is a standard format that is used to store audio files in a Personal Computer Generally when an audio file is in the WAVE file format it is an uncompressed version of the audio sample As mentioned in the previous section the WAVE file is a type of RIFF file with a specific type of format To see the WAVE file format refer to the diagram below Subchunk2 Size re abl Subchunk21D dat
27. nt if SaveFile gt ShowModal wxID_ OK wxString temp2 SaveFile gt GetPath textbox2 gt SetValue temp2 wxString temp textboxl gt GetValue 34 Write the same file FILE fhandle fopen temp2 wb fwri ChunkID 1 4 fhandle fwri amp ChunkSize 4 1 fhandle fwri Format 1 4 fhandle fwri Subchunk11D 1 4 fhandle te te te te fwrite amp Subchunk1Size 4 1 fhandle fwrite s AudioFormat 2 1 fhandle fwrite amp NumChannels 2 1 fhandle te te te te te te fwri SampleRate 4 1 fhandle fwri amp ByteRate 4 1 fhandle fwri BlockAlign 2 1 fhandle fwri amp BitsPerSample 2 1 fhandle fwri Subchunk21D 1 4 fhandle fwri amp Subchunk2Size 4 1 fhandle fwrite ResizedData BitsPerSample 8 Subchunk2Size BitsPerSample 8 fhandle fclose fhandle void Audio Resolution ChangerFrm WxclearClick wxCommandEvent event samplenum gt SetValue originalsample gt SetValue resizedsample gt SetValue Samples gt SetValue AveAbsError gt SetValue Di TotalAbsError gt SetValue AddMaxAbsError gt SetValue MaxAbsError gt SetValue bitsize gt SetSelection 1 textboxl gt SetValue
28. ommandEvent event 22 void samplenumSelected wxCommandEvent amp event void Audio Resolution ChangerFrm WxBackClick wxCommandEvent event void Audio Resolution ChangerFrm WxNextClick wxCommandEvent event void binaryClick wxCommandEvent event void decimalClick wxCommandEvent amp event private Do not add custom control declarations between GUI Control Declaration Start and GUI Control Declaration End wxDev C will remove them Add custom code after the block GUI Control Declaration Start wxMessageDialog sampleerror wxFileDialog OpenFile wxMessageDialog bitratecheck wxMessageDialog bitmessage wxFileDialog SaveFile wxStaticText WxStaticText6 wxTextCtrl AddMaxAbsError wxTextCtrl MaxAbsError wxStaticText WxStaticText5 wxButton Next wxButton back wxButton gotosample wxTextCtrl samplenum wxStaticText WxStaticText4 wxChoice bitsize wxButton clear wxTextCtrl AveAbsError wxStaticText WxStaticText8 wxStaticText WxStaticText7 wxStaticText Sample wxTextCtrl resizedsample wxTextCtrl originalsample wxTextCtrl TotalAbsError wxTextCtrl Samples wxStaticText WxStaticText3 wxStaticText WxStaticText2 wxStaticText WxStaticTextl wxTextCtrl textbox1 23 wxButton Save wxTextCtrl textbox2 wxButton OpenButton GUI Control Declaration End private Note if you receive
29. on resizerapp cpp audio file resolution resizerapp h audio file resolution resizerapp rc When starting the code these files are automatically generated and in this program s case the audio file resolution resizerfrm cpp and audio file resolution_resizerfrm wxform files were the only ones edited Adding objects to the frame were done in the audio file resolution resizerfrm wxform file while the functions for these objects as well as algorithms and such that needed to be coded were defined in the audio file resolution resizerfrm cpp file The audio file resolution resizerapp cpp simply calls for the frame and allows the program to be shown on your window audio file resolution resizerFrm h is where the functions you have defined are declared automatically once you ve used them in the audio file resolution resizerFrm cpp file The audio file resolution resizerapp h declares the the class to be implemented by audio file resolution resizerapp cpp in this case the class is audio resolution changerfrmapp The audio file resolution resizerapp rc was auto generated and didn t contain anything as we didn t import any files for the code 18 Appendix 1 User s Manual A1 1 Software Overview A1 1 1 Features e Load save WAV files e Selectable bit resolution size 1 15 e Display data statistics Display and compare samples A1 2User s Guide A1 2 1 Using the Software Run Audio Resolution Changer exe located at the software folder
30. short tsPerSampl e 8 fread Origina itsPerSamp fclose fhand e 8 e numberofsampl 4 es BitsPerSample Data BitsPerSam fhandle Subchunk2Size ple 8 Subchunk2Size Reading raw audio data Subchunk2Size BitsPerSample 8 16 bitratecheck gt ShowModal numberofsamples 0 Audio Resolution ChangerFrmActivate Ay 32 void Audio Resolution ChangerFrm Audio Resolution ChangerFrmAct ivate wxActivateEvent amp event insert your code here WxMemolUpdated Z textboxUpdated ei void Audio Resolution ChangerFrm textboxUpdated wxCommandEvent event insert your code here bitsizeSelected s void Audio Resolution ChangerFrm bitsizeSelected wxCommandEvent amp event if numberofsamples 0 bitmessage gt ShowModal else int temp bitsize gt GetCurrentSelection BitSize temp l initialize TotalAbsoluteError 0 MaxAbsoluteError 0 AddressMaxAbsoluteError 0 create arrays after obtaining number of samples AbsoluteError new short Subchunk2Size BitsPerSample 8 ResizedData new short Subchunk2Size BitsPerSample 8 for int b 0 b lt Subchunk2Size BitsPerSample 8 b routine to down then upconvert ResizedData b OriginalData b gt gt 16 BitSize lt lt 16 BitSize
31. udio Resolution ChangerFrmApp OnExit return 0 A2 1 5 audio file resolution resizerapp rc Name Audio Resolution ChangerApp rc Author Jan Michael Abuzo Jose Arguelles Francis Cruz Created 1 1 2002 10 40 22 AM Description include lt wx msw wx rc gt A2 1 6 audio file resolution resizerapp cpp 38 Name Audio Resolution ChangerApp cpp Author Jan Michael Abuzo Jose Arguelles Francis Cruz Created 1 1 2002 10 40 22 AM Description include audio file resolution resizerapp h include audio file resolution resizerfrm h IMPLEMENT APP audio resolution changerfrmapp bool audio resolution changerfrmapp OnInit Audio Resolution ChangerFrm frame new Audio Resolution ChangerFrm NULL SetTopWindow frame frame gt Show return true int audio resolution changerfrmapp OnExit return 0 39 Bibliography WAVE PCM soundfile format https ccrma stanford edu courses 422 projects WaveFormat RIFF Format http www daubnet com en file format riff Kreyzig Erwin Advanced Engineering Mathematics Singapore John Wiley amp Sons Inc 2003 40
32. wide short type and the 4 byte wide integer type The character type is used to store the information such as the ChunkID Format Subchunk1ID and Subchunk2ID are declared as a character array with 4 elements The short type is used to store 2 byte numerical information such as AudioFormat NumChannels BlockAlign BitsPerSample and OriginalData OriginalData is declared as a pointer to the data of short type and will later on be dynamically allocated memory space equal to the number of samples in the data chunk Integer type is used for larger sized numerical information such as ChunkSize Subchunk1Size SampleRate ByteRate Subchunk2Size 2 The variable that will store audio data upon conversion is of a short type since the values are only 2 bytes wide The variable ResizedData is declared as a pointer to a data of short type and will also be dynamically allocated some memory equal to the number of samples in the data chunk 3 The statistical data are of integer type float type and short type Those that are integer type are BitSize MaxAbsoluteError and AddressMaxAbsoluteError AverageAbsoluteError and TotalAbsoluteError are declared as float type since the former involves division while the latter involves numbers beyond the scope of long integers Upon declaring them MaxAbsoluteError and TotalAbsoluteError are all initialized to 0 The variable AbsoluteError is declared as a pointer to short type data and will also be dynamical
33. wxTextCtrl this wxSize 114 18 e false Samples new wxPoint 129 134 wxT Samples Samples gt Enabl Samples ID_SAMPLES 0 temSettings GetColour wxSYS_ COLO W WEEE OMS wxDefaultValidator gt SetBackgroundColour wxSystemSettings GetColour wxSYS_ COLO UR_APPWORKSPACE WxStaticText3 ID WXSTATICTEXT3 183 wxDefaultSize WxStaticText2 160 wxDefaultSize WxStaticTextl 136 tSize wxDefaul wxT Total ID WXSTATICTEXT2 wxT Average Absol ID WXSTATICTEXT1 wxT Number of new wxStaticTex 0 wxT TA Absolute Error WxStaticText3 Ed this wxPoint 2 new wxS ticTex ta 0 t this ute Error wxPoint 2 wxT WxStaticText2 new wxStaticText 0 Samples wxT WxStaticText1 this wxPoint 2 0 tex wxT Source Directory wxDefaultValidator textbox Save tboxl new wxTextCtrl 1 this ID TEXTBOX1 gt Enable false wxPoint 0 wxT text new wxButton this ID SAVE 48 wxSize 316 21 tbox1 wxT Save wxPoint 1 303 wxSize 75 25 0 wxDefaultValidator wxT Save textbox2 new wxTextCtrl this ID TEXTBOX2 wxT Destination Directory wxPoint 1 328 wxSize 313 2

Download Pdf Manuals

image

Related Search

Related Contents

! WARNING - Napoleon Products  "user manual"  LA MEDECINE PREVENTIVE : MODE D`EMPLOI  Texte de la thèse  Page 1 Page 2 便利と思って使っている製品の 中には、正しい使い方を  Viewsonic PROJECTOR PJ 551  Supermicro SYS-6015A-NTB server barebone  

Copyright © All rights reserved.
Failed to retrieve file