— Jan Newmarch Linux Sound Programming
Total Page:16
File Type:pdf, Size:1020Kb
Linux Sound Programming — Jan Newmarch Linux Sound Programming Jan Newmarch Linux Sound Programming Jan Newmarch Oakleigh, Victoria, Australia ISBN-13 (pbk): 978-1-4842-2495-3 ISBN-13 (electronic): 978-1-4842-2496-0 DOI 10.1007/978-1-4842-2496-0 Library of Congress Control Number: 2017931692 Copyright © 2017 by Jan Newmarch This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed. Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein. Managing Director: Welmoed Spahr Acquisitions Editor: Steve Anglin Development Editor: Matthew Moodie Technical Reviewer: Jeff Tranter Coordinating Editor: Mark Powers Copy Editor: Kim Wimpsett Compositor: SPi Global Indexer: SPi Global Artist: SPi Global Cover image designed by Freepik Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer- sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation. For information on translations, please e-mail [email protected], or visit http://www.apress.com/rights- permission. Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales web page at http://www.apress.com/bulk-sales. Any source code or other supplementary material referenced by the author in this book is available to readers via the book’s product page, located at www.apress.com/9781484224953. For more detailed information, please visit http://www.apress.com/source-code. Printed on acid-free paper Contents at a Glance About the Author ....................................................................................................xxi About the Technical Reviewer ..............................................................................xxiii ■ Chapter 1: Basic Concepts of Sound...................................................................... 1 ■ Chapter 2: User-Level Tools ................................................................................... 7 ■ Chapter 3: Sound Codecs and File Formats ......................................................... 11 ■ Chapter 4: Overview of Linux Sound Architecture ............................................... 15 ■ Chapter 5: ALSA ................................................................................................... 21 ■ Chapter 6: PulseAudio ......................................................................................... 61 ■ Chapter 7: Jack ................................................................................................. 143 ■ Chapter 8: Session Management ....................................................................... 179 ■ Chapter 9: Java Sound ...................................................................................... 197 ■ Chapter 10: GStreamer ...................................................................................... 211 ■ Chapter 11: libao ............................................................................................... 223 ■ Chapter 12: FFmpeg/Libav................................................................................. 227 ■ Chapter 13: OpenMAX IL .................................................................................... 235 ■ Chapter 14: LADSPA ........................................................................................... 277 ■ Chapter 15: Displaying Video with Overlays Using Gtk and FFmpeg ................. 293 ■ Chapter 16: MIDI ................................................................................................ 317 ■ Chapter 17: User-Level Tools for MIDI ............................................................... 321 ■ Chapter 18: MIDI Java Sound ............................................................................ 327 iii ■ CONTENTS AT A GLANCE ■ Chapter 19: MIDI ALSA ...................................................................................... 343 ■ Chapter 20: FluidSynth ...................................................................................... 351 ■ Chapter 21: TiMidity .......................................................................................... 355 ■ Chapter 22: Overview of Karaoke Systems ....................................................... 369 ■ Chapter 23: Karaoke User-Level Tools ............................................................... 371 ■ Chapter 24: MP3+G ........................................................................................... 381 ■ Chapter 25: Karaoke Applications Using Java Sound ........................................ 407 ■ Chapter 26: Subtitles and Closed Captions ....................................................... 443 ■ Chapter 27: Karaoke FluidSynth ........................................................................ 465 ■ Chapter 28: TiMidity and Karaoke ..................................................................... 499 ■ Chapter 29: Jack and Karaoke .......................................................................... 523 ■ Chapter 30: Streaming Audio ............................................................................ 533 ■ Chapter 31: Raspberry Pi .................................................................................. 537 ■ Chapter 32: Conclusion ..................................................................................... 547 ■ Appendix A: Decoding the DKD Files on the Sonken Karaoke DVD .................... 549 Index ..................................................................................................................... 603 iv Contents About the Author ....................................................................................................xxi About the Technical Reviewer ..............................................................................xxiii ■ Chapter 1: Basic Concepts of Sound...................................................................... 1 Sampled Audio ����������������������������������������������������������������������������������������������������������������� 1 Sample Rate ��������������������������������������������������������������������������������������������������������������������� 1 Sample Format ����������������������������������������������������������������������������������������������������������������� 2 Frames ����������������������������������������������������������������������������������������������������������������������������� 2 Pulse-Code Modulation ���������������������������������������������������������������������������������������������������� 2 Overrun and Underrun ������������������������������������������������������������������������������������������������������ 3 Latency ����������������������������������������������������������������������������������������������������������������������������� 3 Jitter ��������������������������������������������������������������������������������������������������������������������������������� 4 Mixing ������������������������������������������������������������������������������������������������������������������������������� 5 Conclusion ������������������������������������������������������������������������������������������������������������������������ 5 ■ Chapter 2: User-Level Tools ................................................................................... 7 Players������������������������������������������������������������������������������������������������������������������������������ 7 MPlayer ���������������������������������������������������������������������������������������������������������������������������������������������������7 VLC����������������������������������������������������������������������������������������������������������������������������������������������������������7 Totem ������������������������������������������������������������������������������������������������������������������������������������������������������8 v ■ CONTENTS Sound Tools ����������������������������������������������������������������������������������������������������������������������