SlideShare une entreprise Scribd logo
1  sur  11
Télécharger pour lire hors ligne
Basic audio programming
Iulian Şerbănoiu - March 2010
Contents
●Basic notions
○Sample
○Sample rate
○Audio bit depth
●Example
○portaudio
●Other audio libraries
●References
Basic notions - sample
Each square ( <fi
> i=1..12
) represents a sample
Basic notions - sample rate
Sample rate = number of samples in a second
greater T -> smaller sample rate -> lower quality
smaller T -> greater sample rate -> higher quality
Basic notions - audio bit depth
Bit depth = number of bits in each sample
Common bit depths
●8 bit (signed/unsigned)
●16 bit (signed) - CD quality
●32 bit integer (signed)
●32 bit float (values ranging from -1 to 1)
Greater bit depth -> better sound quality -> more space needed
Example - portaudio (init/terminate)
Tipical portaudio usage:
Pa_Initialize();
...
DoMyPortaudioSoundOperations();
...
Pa_Terminate();
hg clone http://minvg.hg.sourceforge.net:8000/hgroot/minvg; cd minvg/trunk/PortaudioSoundPlayer
Example - portaudio init/close stream
In portaudio, the stream is the primitive for sound
processing
Pa_Open(Default)Stream(
....
);
Pa_CloseStream(createdStream);
hg clone http://minvg.hg.sourceforge.net:8000/hgroot/minvg; cd minvg/trunk/PortaudioSoundPlayer
Example - portaudio stream parameters
The stream creation function receives the following
parameters:
●number of Input/Output channels
●sample rate, bit depth
●processing callback and callback buffer size
●user data that can be passed to the callback
hg clone http://minvg.hg.sourceforge.net:8000/hgroot/minvg; cd minvg/trunk/PortaudioSoundPlayer
Example - portaudio callback
The callback is (asynchronously!) called periodically when:
●new input data arrived (when recording)
●new output data requested
int Callback(const void *input, void *output, ... );
Return values:
●paComplete - to end playing/recording after this call
●paContinue - to continue playing/recording
●paAbort - to end playing/recording ASAP
hg clone http://minvg.hg.sourceforge.net:8000/hgroot/minvg; cd minvg/trunk/PortaudioSoundPlayer
Other audio libraries
●RtAudio
○similar to portaudio (callback mechanism)
○object oriented design (C++)
●libsdl (audio component)
○similar to portaudio (callback mechanism)
○game development oriented
●OpenAL
○API similar to OpenGL
○higher level interface (compared to portaudio)
○game development oriented
References
Basic information
http://en.wikipedia.org/wiki/Sample_%28signal%2
http://www.tweakheadz.com/16_vs_24_bit_audio.htm
http://en.wikipedia.org/wiki/Sampling_rate
http://en.wikipedia.org/wiki/Audio_bit_depth
Audio libraries
http://www.music.mcgill.ca/~gary/rtaudio/
http://connect.creativelabs.com/openal
http://www.portaudio.com/
http://www.libsdl.org/
General information
http://www.dspguide.com/

Contenu connexe

En vedette

FoundationsofAudio_EQandFilters_CertificateOfCompletion
FoundationsofAudio_EQandFilters_CertificateOfCompletionFoundationsofAudio_EQandFilters_CertificateOfCompletion
FoundationsofAudio_EQandFilters_CertificateOfCompletionZack Logan
 
Design and Implement Any Digital Filters in Less than 60 Seconds
Design and Implement Any Digital Filters in Less than 60 SecondsDesign and Implement Any Digital Filters in Less than 60 Seconds
Design and Implement Any Digital Filters in Less than 60 SecondsMike Ellis
 
Fir filter design (windowing technique)
Fir filter design (windowing technique)Fir filter design (windowing technique)
Fir filter design (windowing technique)Bin Biny Bino
 
Fir and iir filter_design
Fir and iir filter_designFir and iir filter_design
Fir and iir filter_designshrinivasgnaik
 
Basic computer configuration setup
Basic computer configuration setupBasic computer configuration setup
Basic computer configuration setupRachel Espino
 
Basics of Digital Filters
Basics of Digital FiltersBasics of Digital Filters
Basics of Digital Filtersop205
 
Design of FIR filters
Design of FIR filtersDesign of FIR filters
Design of FIR filtersop205
 

En vedette (12)

FoundationsofAudio_EQandFilters_CertificateOfCompletion
FoundationsofAudio_EQandFilters_CertificateOfCompletionFoundationsofAudio_EQandFilters_CertificateOfCompletion
FoundationsofAudio_EQandFilters_CertificateOfCompletion
 
Design and Implement Any Digital Filters in Less than 60 Seconds
Design and Implement Any Digital Filters in Less than 60 SecondsDesign and Implement Any Digital Filters in Less than 60 Seconds
Design and Implement Any Digital Filters in Less than 60 Seconds
 
Signals
SignalsSignals
Signals
 
Fir filter design (windowing technique)
Fir filter design (windowing technique)Fir filter design (windowing technique)
Fir filter design (windowing technique)
 
Electronics ..
Electronics ..Electronics ..
Electronics ..
 
Fir and iir filter_design
Fir and iir filter_designFir and iir filter_design
Fir and iir filter_design
 
Basic computer configuration setup
Basic computer configuration setupBasic computer configuration setup
Basic computer configuration setup
 
Digital audio
Digital audioDigital audio
Digital audio
 
Active Filter (Low Pass)
Active Filter (Low Pass)Active Filter (Low Pass)
Active Filter (Low Pass)
 
Basics of Digital Filters
Basics of Digital FiltersBasics of Digital Filters
Basics of Digital Filters
 
Filters
FiltersFilters
Filters
 
Design of FIR filters
Design of FIR filtersDesign of FIR filters
Design of FIR filters
 

Similaire à Basic audio programming

Digital Electronics for Audio
Digital Electronics for AudioDigital Electronics for Audio
Digital Electronics for Audiojazztothebone
 
Jordan smith ig2 task 1 work sheet v2
Jordan smith ig2 task 1 work sheet v2Jordan smith ig2 task 1 work sheet v2
Jordan smith ig2 task 1 work sheet v2JordanSmith96
 
Audio encoding principles
Audio encoding principlesAudio encoding principles
Audio encoding principlesPhillip Doyle
 
Sound recording glossary improved
Sound recording glossary improvedSound recording glossary improved
Sound recording glossary improvedItsLiamOven
 
Sound recording glossary by Liam Oven for Unit 73
Sound recording glossary by Liam Oven for Unit 73Sound recording glossary by Liam Oven for Unit 73
Sound recording glossary by Liam Oven for Unit 73ItsLiamOven
 
Ig2 task 1 work sheet
Ig2 task 1 work sheetIg2 task 1 work sheet
Ig2 task 1 work sheetJoshCollege
 
IG2 Task 1 Work Sheet
IG2 Task 1 Work SheetIG2 Task 1 Work Sheet
IG2 Task 1 Work SheetNathan_West
 
Ig2 task 1 work sheet 2
Ig2 task 1 work sheet 2Ig2 task 1 work sheet 2
Ig2 task 1 work sheet 2JoeBrannigan
 
Scct2013 topic 4_audio
Scct2013 topic 4_audioScct2013 topic 4_audio
Scct2013 topic 4_audioAnies Syahieda
 
Sound recording glossarygggg
Sound recording glossaryggggSound recording glossarygggg
Sound recording glossarygggganthonynewman
 

Similaire à Basic audio programming (20)

Digital Electronics for Audio
Digital Electronics for AudioDigital Electronics for Audio
Digital Electronics for Audio
 
Jordan smith ig2 task 1 work sheet v2
Jordan smith ig2 task 1 work sheet v2Jordan smith ig2 task 1 work sheet v2
Jordan smith ig2 task 1 work sheet v2
 
3 workingwithsoundaudacity
3 workingwithsoundaudacity3 workingwithsoundaudacity
3 workingwithsoundaudacity
 
MultiMedia-Lecture-4.pptx
MultiMedia-Lecture-4.pptxMultiMedia-Lecture-4.pptx
MultiMedia-Lecture-4.pptx
 
Ch05
Ch05Ch05
Ch05
 
Audio encoding principles
Audio encoding principlesAudio encoding principles
Audio encoding principles
 
Sound recording glossary improved
Sound recording glossary improvedSound recording glossary improved
Sound recording glossary improved
 
Sound recording glossary by Liam Oven for Unit 73
Sound recording glossary by Liam Oven for Unit 73Sound recording glossary by Liam Oven for Unit 73
Sound recording glossary by Liam Oven for Unit 73
 
CHAPTER – 5 Audio
CHAPTER – 5     AudioCHAPTER – 5     Audio
CHAPTER – 5 Audio
 
Digital audio
Digital audioDigital audio
Digital audio
 
Sound.pptx
Sound.pptxSound.pptx
Sound.pptx
 
Ig2 task 1 work sheet
Ig2 task 1 work sheetIg2 task 1 work sheet
Ig2 task 1 work sheet
 
IG2 Task 1 Work Sheet
IG2 Task 1 Work SheetIG2 Task 1 Work Sheet
IG2 Task 1 Work Sheet
 
Call audio
Call audioCall audio
Call audio
 
Audio compression
Audio compressionAudio compression
Audio compression
 
Ig2 task 1 work sheet 2
Ig2 task 1 work sheet 2Ig2 task 1 work sheet 2
Ig2 task 1 work sheet 2
 
Scct2013 topic 4_audio
Scct2013 topic 4_audioScct2013 topic 4_audio
Scct2013 topic 4_audio
 
Voiceovers
VoiceoversVoiceovers
Voiceovers
 
Voiceovers
VoiceoversVoiceovers
Voiceovers
 
Sound recording glossarygggg
Sound recording glossaryggggSound recording glossarygggg
Sound recording glossarygggg
 

Dernier

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businesspanagenda
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesBoston Institute of Analytics
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024The Digital Insurer
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 

Dernier (20)

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 

Basic audio programming