SlideShare a Scribd company logo
1 of 31
Download to read offline
Python For Audio Signal Processing
Linux Audio Conference 2011
National University of Ireland, Maynooth
7th May 2011
John Glover
The Sound and Digital Music Research Group
National University of Ireland, Maynooth
Overview
Look at Python programming language and libraries for scientific
computing:
• NumPy
• SciPy
• Matplotlib
Overview
Show how Python was used to create 2 audio programming
libraries:
• Modal
• Simpl
Describe Python integration with other tools:
• The SndObj Library
• Pure Data
Introduction
There are many common problems in audio signal processing:
• loading sound files
• communication with sound cards
• DSP tasks (filtering, Fourier analysis, etc)
Generally makes sense to rely on frameworks/libraries for these sort
of tasks, particularly when prototyping.
Introduction
Audio programming libraries exist for many general purpose
programming languages, eg: C/C++
Can result in long development times
This is one of the factors that fuels the popularity of tools such as
Matlab.
Introduction
Problems with MATLAB:
• Expensive
• Not open source, harder to share work
GNU Octave: an open source alternative to MATLAB
• Interpreted
• Similar syntax to MATLAB
Introduction
Other issues with MATLAB/Octave:
• Complex development greatly aided by tools such as IDEs,
debuggers, profilers. Exist in some form for MATLAB/Octave,
more time spent on tools for a domain with limited scope.
• Don’t integrate as well with compositional tools such as
Csound and Pure Data, or with web frameworks, mobile
applications, etc.
Introduction
Desirable features in an environment for prototyping audio signal
processing applications:
• Power/flexibility of an open source, widely adopted general
purpose programming language
• Quick development process of interpreted, dynamic languages
• Large collection of signal processing tools/libraries
• Easy integration with existing tools/solutions
Python meets all of these criteria.
Python
• Open source
• Runs on all major platforms
• Widely used
• Actively developed
• Vast array of libraries and development tools
Python
• Multi-paradigm
• Clean syntax, very readable code (executable pseudocode)
• Interactive interpreter, useful for experimentation / live coding
• Very easy to extend using C/C++, so can optimise later.
Python
• Can be embedded into existing applications
• Documentation can be generated automatically from
comments and source code
• Python bindings exist for cross-platform GUI toolkits (eg: Qt)
More information and comprehensive tutorial at: http://python.org
Python For Scientific Computing
Python’s scientific computing prowess comes largely from a
combination of 3 related modules:
• NumPy
• SciPy
• Matplotlib
Python For Scientific Computing
NumPy:
• Adds homogeneous, multi-dimensional array objects and
functions that perform efficient calculations using them.
• Syntax is like a Pythonic MATLAB
• Written in C, easily extended via C API
• Includes f2py to create Python extension modules from
Fortran code
Python For Scientific Computing
SciPy:
• Builds on top of NumPy, providing modules dedicated to
common issues in scientific computing
• Similar to MATLAB toolboxes
A full list of modules is available at: http://docs.scipy.org, but
examples include:
• scipy.io: file input/output
• scipy.fftpack: Fourier transforms
• scipy.signal: signal processing functions
• scipy.interpolate: linear interpolation, cubic splines
• scipy.linalg: linear algebra
Python For Scientific Computing
Matplotlib:
• Library of 2D plotting functions
• Adds ability to visualise data from NumPy arrays
• Produces publication ready figures in a variety of formats
• Can be used interactively or from scripts, with GUI toolkits or
from web apps.
• Similar functionality to GNU plot
SciPy Examples
• Plot audio waveform
• Plot FFT data
Simpl
Simpl is an open source library (GPL) for sinusoidal modelling
written in C/C++ and Python.
The aim of this project is to tie together many of the existing
sinusoidal modelling implementations into a single unified system
with a consistent API, as well as provide implementations of some
recently published sinusoidal modelling algorithms.
Simpl is primarily intended as a tool for other researchers in the
field, allowing them to easily combine, compare and contrast many
of the published analysis/synthesis algorithms.
Simpl
Simpl breaks the sinusoidal modelling process down into three
distinct steps:
• Peak detection
• Partial tracking
• Sound synthesis
Implementations have a Python module associated with every step
which returns data in the same format, irrespective of its
underlying implementation.
This allows analysis/synthesis networks to be created in which the
algorithm that is used for a particular step can be changed without
effecting the rest of the network.
Simpl: Use of SciPy
All audio in Simpl is stored in NumPy arrays. This means that
SciPy functions can be used for:
• Basic tasks such as reading and writing audio files
• Performing additional processing / analysis
• Data visualisation
Simpl: Use of SciPy
Audio samples are passed into a PeakDetection object for analysis,
with detected peaks being returned as NumPy arrays that are used
to build a list of Peak objects.
Peaks are then passed to PartialTracking objects, which return
partials that can be transferred to Synthesis objects to create a
NumPy array of synthesised audio samples.
Simpl also includes a module with plotting functions that use
Matplotlib to plot analysis data from the peak detection and
partial tracking analysis phases.
Modal
Modal is a new open source library (GPL) for musical onset
detection, written in C++ and Python.
Consists of two main components: a code library and a database of
audio samples.
Modal: Code Library
• Includes implementations of three widely used onset detection
algorithms from the literature and four novel onset detection
systems created by the authors.
• The onset detection systems can work in a real-time
streaming situation as well as in non-real-time.
• Details in our upcoming paper, to be published in the
EURASIP Journal on Advances in Signal Processing
Modal: Sample Database
• Database contains a collection of audio samples that have
creative commons licensing allowing for free reuse and
redistribution, together with hand-annotated onset locations
for each sample.
• Includes an application that allows for the labelling of onset
locations in audio files, which can then be added to the
database.
Modal: Sample Database
• To the best of our knowledge, this is the only freely
distributable database of audio samples together with their
onset locations that is currently available.
• The Sound Onset Labellizer is a similar reference collection,
but was not available at the time of publication.
• The sample set used by the Sound Onset Labellizer also makes
use of files from the RWC database, which although publicly
available is not free and does not allow free redistribution.
Modal: Use of SciPy
• Extensive use of SciPy, with NumPy arrays being used to
contain audio samples and analysis data from multiple stages
of the onset detection process including computed onset
detection functions, peak picking thresholds and the detected
onset locations.
• Matplotlib is used to plot the analysis results.
• All of the onset detection algorithms were written in Python
and make use of SciPy’s signal processing modules.
Modal: Use of SciPy
• The most computationally expensive part of the onset
detection process is the calculation of the onset detection
functions, so Modal also includes C++ implementations of all
onset detection function modules.
• Made into Python extension modules using SWIG.
• This allows Python to be used in areas that it excels in such
as rapid prototyping and in “glueing” related components
together, while languages such as C and C++ can be used
later in the development cycle to optimise specific modules if
necessary.
Python Integration With Other Tools
Going to look at Python integration with:
• The SndObj Library
• Pure Data
However, Python bindings do exist for other popular open-source
composition tools:
• Csound
• SuperCollider
The SndObj Library
• Recent version of The SndObj Library comes with support for
passing NumPy arrays to and from objects in the library,
• This allows data to be easily exchanged between SndObj and
SciPy audio processing networks/functions.
Pure Data
• libpd allows Pure Data to be embedded as a DSP library. and
• It comes with a SWIG wrapper enabling it to be loaded as a
Python extension module.
• NumPy arrays can be passed to/from Pd patches.
Conclusions
This paper highlighted just a few of the many features that make
Python an excellent choice for developing audio signal processing
applications:
• Clean, readable syntax
• Quick development times
• An extensive collection of libraries
• Unrestrictive open source license
Discussed two open source signal processing libraries created by
the authors that both make use of Python and SciPy: Simpl and
Modal.
Python is easy to extend and integrates well with other
programming languages and environments.
Questions?
Software mentioned in this talk:
• Python programming language: http://python.org
• NumPy & SciPy: http://scipy.org
• Matplotlib: http://matplotlib.sourceforge.net
• Simpl: http://simplsound.sourceforge.net
• Modal: http://github.com/johnglover/modal
• The SndObj Library: http://sndobj.sourceforge.net
• libpd: http://gitorious.org/pdlib
• My examples: http://github.com/johnglover/pfasp-examples

More Related Content

Similar to Python For Audio Signal Processing ( PDFDrive ).pdf

Introduction to Jupyter notebook and MS Azure Machine Learning Studio
Introduction to Jupyter notebook and MS Azure Machine Learning StudioIntroduction to Jupyter notebook and MS Azure Machine Learning Studio
Introduction to Jupyter notebook and MS Azure Machine Learning StudioMuralidharan Deenathayalan
 
Introduction to Jupyter notebook and MS Azure Machine Learning Studio
Introduction to Jupyter notebook and MS Azure Machine Learning StudioIntroduction to Jupyter notebook and MS Azure Machine Learning Studio
Introduction to Jupyter notebook and MS Azure Machine Learning StudioMuralidharan Deenathayalan
 
Python standard library & list of important libraries
Python standard library & list of important librariesPython standard library & list of important libraries
Python standard library & list of important librariesgrinu
 
Python programming
Python programmingPython programming
Python programmingMegha V
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to pythonMohammed Rafi
 
Introduction to Python Programming
Introduction to Python ProgrammingIntroduction to Python Programming
Introduction to Python ProgrammingAkhil Kaushik
 
OpenSAF Symposium_Python Bindings_9.21.11
OpenSAF Symposium_Python Bindings_9.21.11OpenSAF Symposium_Python Bindings_9.21.11
OpenSAF Symposium_Python Bindings_9.21.11OpenSAF Foundation
 
ANN-Lecture2-Python Startup.pptx
ANN-Lecture2-Python Startup.pptxANN-Lecture2-Python Startup.pptx
ANN-Lecture2-Python Startup.pptxShahzadAhmadJoiya3
 
CSP as a Domain-Specific Language Embedded in Python and Jython
CSP as a Domain-Specific Language Embedded in Python and JythonCSP as a Domain-Specific Language Embedded in Python and Jython
CSP as a Domain-Specific Language Embedded in Python and JythonM H
 
Python programming language introduction unit
Python programming language introduction unitPython programming language introduction unit
Python programming language introduction unitmichaelaaron25322
 
Building cloud-enabled genomics workflows with Luigi and Docker
Building cloud-enabled genomics workflows with Luigi and DockerBuilding cloud-enabled genomics workflows with Luigi and Docker
Building cloud-enabled genomics workflows with Luigi and DockerJacob Feala
 
Introduction to Python Programming Basics
Introduction  to  Python  Programming BasicsIntroduction  to  Python  Programming Basics
Introduction to Python Programming BasicsDhana malar
 
Python indroduction
Python indroductionPython indroduction
Python indroductionFEG
 
Python for MATLAB Programmers
Python for MATLAB ProgrammersPython for MATLAB Programmers
Python for MATLAB ProgrammersMichael Patterson
 

Similar to Python For Audio Signal Processing ( PDFDrive ).pdf (20)

What is python
What is pythonWhat is python
What is python
 
Introduction to Jupyter notebook and MS Azure Machine Learning Studio
Introduction to Jupyter notebook and MS Azure Machine Learning StudioIntroduction to Jupyter notebook and MS Azure Machine Learning Studio
Introduction to Jupyter notebook and MS Azure Machine Learning Studio
 
Introduction to Jupyter notebook and MS Azure Machine Learning Studio
Introduction to Jupyter notebook and MS Azure Machine Learning StudioIntroduction to Jupyter notebook and MS Azure Machine Learning Studio
Introduction to Jupyter notebook and MS Azure Machine Learning Studio
 
Python standard library & list of important libraries
Python standard library & list of important librariesPython standard library & list of important libraries
Python standard library & list of important libraries
 
Python programming
Python programmingPython programming
Python programming
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
PyData Boston 2013
PyData Boston 2013PyData Boston 2013
PyData Boston 2013
 
Introduction to Python Programming
Introduction to Python ProgrammingIntroduction to Python Programming
Introduction to Python Programming
 
OpenSAF Symposium_Python Bindings_9.21.11
OpenSAF Symposium_Python Bindings_9.21.11OpenSAF Symposium_Python Bindings_9.21.11
OpenSAF Symposium_Python Bindings_9.21.11
 
Presentation.pptx
Presentation.pptxPresentation.pptx
Presentation.pptx
 
Presentation.pptx
Presentation.pptxPresentation.pptx
Presentation.pptx
 
ANN-Lecture2-Python Startup.pptx
ANN-Lecture2-Python Startup.pptxANN-Lecture2-Python Startup.pptx
ANN-Lecture2-Python Startup.pptx
 
CSP as a Domain-Specific Language Embedded in Python and Jython
CSP as a Domain-Specific Language Embedded in Python and JythonCSP as a Domain-Specific Language Embedded in Python and Jython
CSP as a Domain-Specific Language Embedded in Python and Jython
 
Python programming language introduction unit
Python programming language introduction unitPython programming language introduction unit
Python programming language introduction unit
 
Cmpe202 01 Research
Cmpe202 01 ResearchCmpe202 01 Research
Cmpe202 01 Research
 
Building cloud-enabled genomics workflows with Luigi and Docker
Building cloud-enabled genomics workflows with Luigi and DockerBuilding cloud-enabled genomics workflows with Luigi and Docker
Building cloud-enabled genomics workflows with Luigi and Docker
 
Introduction to Python Programming Basics
Introduction  to  Python  Programming BasicsIntroduction  to  Python  Programming Basics
Introduction to Python Programming Basics
 
Python indroduction
Python indroductionPython indroduction
Python indroduction
 
Python Tutorial Part 2
Python Tutorial Part 2Python Tutorial Part 2
Python Tutorial Part 2
 
Python for MATLAB Programmers
Python for MATLAB ProgrammersPython for MATLAB Programmers
Python for MATLAB Programmers
 

Recently uploaded

APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and usesDevarapalliHaritha
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 

Recently uploaded (20)

APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
Design and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdfDesign and analysis of solar grass cutter.pdf
Design and analysis of solar grass cutter.pdf
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
power system scada applications and uses
power system scada applications and usespower system scada applications and uses
power system scada applications and uses
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 

Python For Audio Signal Processing ( PDFDrive ).pdf

  • 1. Python For Audio Signal Processing Linux Audio Conference 2011 National University of Ireland, Maynooth 7th May 2011 John Glover The Sound and Digital Music Research Group National University of Ireland, Maynooth
  • 2. Overview Look at Python programming language and libraries for scientific computing: • NumPy • SciPy • Matplotlib
  • 3. Overview Show how Python was used to create 2 audio programming libraries: • Modal • Simpl Describe Python integration with other tools: • The SndObj Library • Pure Data
  • 4. Introduction There are many common problems in audio signal processing: • loading sound files • communication with sound cards • DSP tasks (filtering, Fourier analysis, etc) Generally makes sense to rely on frameworks/libraries for these sort of tasks, particularly when prototyping.
  • 5. Introduction Audio programming libraries exist for many general purpose programming languages, eg: C/C++ Can result in long development times This is one of the factors that fuels the popularity of tools such as Matlab.
  • 6. Introduction Problems with MATLAB: • Expensive • Not open source, harder to share work GNU Octave: an open source alternative to MATLAB • Interpreted • Similar syntax to MATLAB
  • 7. Introduction Other issues with MATLAB/Octave: • Complex development greatly aided by tools such as IDEs, debuggers, profilers. Exist in some form for MATLAB/Octave, more time spent on tools for a domain with limited scope. • Don’t integrate as well with compositional tools such as Csound and Pure Data, or with web frameworks, mobile applications, etc.
  • 8. Introduction Desirable features in an environment for prototyping audio signal processing applications: • Power/flexibility of an open source, widely adopted general purpose programming language • Quick development process of interpreted, dynamic languages • Large collection of signal processing tools/libraries • Easy integration with existing tools/solutions Python meets all of these criteria.
  • 9. Python • Open source • Runs on all major platforms • Widely used • Actively developed • Vast array of libraries and development tools
  • 10. Python • Multi-paradigm • Clean syntax, very readable code (executable pseudocode) • Interactive interpreter, useful for experimentation / live coding • Very easy to extend using C/C++, so can optimise later.
  • 11. Python • Can be embedded into existing applications • Documentation can be generated automatically from comments and source code • Python bindings exist for cross-platform GUI toolkits (eg: Qt) More information and comprehensive tutorial at: http://python.org
  • 12. Python For Scientific Computing Python’s scientific computing prowess comes largely from a combination of 3 related modules: • NumPy • SciPy • Matplotlib
  • 13. Python For Scientific Computing NumPy: • Adds homogeneous, multi-dimensional array objects and functions that perform efficient calculations using them. • Syntax is like a Pythonic MATLAB • Written in C, easily extended via C API • Includes f2py to create Python extension modules from Fortran code
  • 14. Python For Scientific Computing SciPy: • Builds on top of NumPy, providing modules dedicated to common issues in scientific computing • Similar to MATLAB toolboxes A full list of modules is available at: http://docs.scipy.org, but examples include: • scipy.io: file input/output • scipy.fftpack: Fourier transforms • scipy.signal: signal processing functions • scipy.interpolate: linear interpolation, cubic splines • scipy.linalg: linear algebra
  • 15. Python For Scientific Computing Matplotlib: • Library of 2D plotting functions • Adds ability to visualise data from NumPy arrays • Produces publication ready figures in a variety of formats • Can be used interactively or from scripts, with GUI toolkits or from web apps. • Similar functionality to GNU plot
  • 16. SciPy Examples • Plot audio waveform • Plot FFT data
  • 17. Simpl Simpl is an open source library (GPL) for sinusoidal modelling written in C/C++ and Python. The aim of this project is to tie together many of the existing sinusoidal modelling implementations into a single unified system with a consistent API, as well as provide implementations of some recently published sinusoidal modelling algorithms. Simpl is primarily intended as a tool for other researchers in the field, allowing them to easily combine, compare and contrast many of the published analysis/synthesis algorithms.
  • 18. Simpl Simpl breaks the sinusoidal modelling process down into three distinct steps: • Peak detection • Partial tracking • Sound synthesis Implementations have a Python module associated with every step which returns data in the same format, irrespective of its underlying implementation. This allows analysis/synthesis networks to be created in which the algorithm that is used for a particular step can be changed without effecting the rest of the network.
  • 19. Simpl: Use of SciPy All audio in Simpl is stored in NumPy arrays. This means that SciPy functions can be used for: • Basic tasks such as reading and writing audio files • Performing additional processing / analysis • Data visualisation
  • 20. Simpl: Use of SciPy Audio samples are passed into a PeakDetection object for analysis, with detected peaks being returned as NumPy arrays that are used to build a list of Peak objects. Peaks are then passed to PartialTracking objects, which return partials that can be transferred to Synthesis objects to create a NumPy array of synthesised audio samples. Simpl also includes a module with plotting functions that use Matplotlib to plot analysis data from the peak detection and partial tracking analysis phases.
  • 21. Modal Modal is a new open source library (GPL) for musical onset detection, written in C++ and Python. Consists of two main components: a code library and a database of audio samples.
  • 22. Modal: Code Library • Includes implementations of three widely used onset detection algorithms from the literature and four novel onset detection systems created by the authors. • The onset detection systems can work in a real-time streaming situation as well as in non-real-time. • Details in our upcoming paper, to be published in the EURASIP Journal on Advances in Signal Processing
  • 23. Modal: Sample Database • Database contains a collection of audio samples that have creative commons licensing allowing for free reuse and redistribution, together with hand-annotated onset locations for each sample. • Includes an application that allows for the labelling of onset locations in audio files, which can then be added to the database.
  • 24. Modal: Sample Database • To the best of our knowledge, this is the only freely distributable database of audio samples together with their onset locations that is currently available. • The Sound Onset Labellizer is a similar reference collection, but was not available at the time of publication. • The sample set used by the Sound Onset Labellizer also makes use of files from the RWC database, which although publicly available is not free and does not allow free redistribution.
  • 25. Modal: Use of SciPy • Extensive use of SciPy, with NumPy arrays being used to contain audio samples and analysis data from multiple stages of the onset detection process including computed onset detection functions, peak picking thresholds and the detected onset locations. • Matplotlib is used to plot the analysis results. • All of the onset detection algorithms were written in Python and make use of SciPy’s signal processing modules.
  • 26. Modal: Use of SciPy • The most computationally expensive part of the onset detection process is the calculation of the onset detection functions, so Modal also includes C++ implementations of all onset detection function modules. • Made into Python extension modules using SWIG. • This allows Python to be used in areas that it excels in such as rapid prototyping and in “glueing” related components together, while languages such as C and C++ can be used later in the development cycle to optimise specific modules if necessary.
  • 27. Python Integration With Other Tools Going to look at Python integration with: • The SndObj Library • Pure Data However, Python bindings do exist for other popular open-source composition tools: • Csound • SuperCollider
  • 28. The SndObj Library • Recent version of The SndObj Library comes with support for passing NumPy arrays to and from objects in the library, • This allows data to be easily exchanged between SndObj and SciPy audio processing networks/functions.
  • 29. Pure Data • libpd allows Pure Data to be embedded as a DSP library. and • It comes with a SWIG wrapper enabling it to be loaded as a Python extension module. • NumPy arrays can be passed to/from Pd patches.
  • 30. Conclusions This paper highlighted just a few of the many features that make Python an excellent choice for developing audio signal processing applications: • Clean, readable syntax • Quick development times • An extensive collection of libraries • Unrestrictive open source license Discussed two open source signal processing libraries created by the authors that both make use of Python and SciPy: Simpl and Modal. Python is easy to extend and integrates well with other programming languages and environments.
  • 31. Questions? Software mentioned in this talk: • Python programming language: http://python.org • NumPy & SciPy: http://scipy.org • Matplotlib: http://matplotlib.sourceforge.net • Simpl: http://simplsound.sourceforge.net • Modal: http://github.com/johnglover/modal • The SndObj Library: http://sndobj.sourceforge.net • libpd: http://gitorious.org/pdlib • My examples: http://github.com/johnglover/pfasp-examples