Siêu thị PDFTải ngay đi em, trời tối mất

Thư viện tri thức trực tuyến

Kho tài liệu với 50,000+ tài liệu học thuật

© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

The Audio Programming Book
PREMIUM
Số trang
916
Kích thước
11.2 MB
Định dạng
PDF
Lượt xem
1064

The Audio Programming Book

Nội dung xem thử

Mô tả chi tiết

THE AUDIO

PROGRAMMING BOOK

e <stdio.h> #include <stdio.h> define SAMPLING_RATE 44100 #define NUM

SECONDS * SAMPLING_RATE)

nclude <stdio.h> #include <stdio.h> define SAMPLING_R #include <stdio.h> #include <stdio.h> define SAMPLING_RATE 44100 #define NUM_SECONDS 3 #define NUM_SAMPLES

NUM_SECONDS * SAMPLING_RATE)

EDITED BY RICHARD BOULANGER AND VICTOR LAZZARINI

FOREWORD BY MAX MATHEWS

The Audio Programming Book

The Audio Programming Book

edited by Richard Boulanger and Victor Lazzarini

foreword by Max V. Mathews

The MIT Press

Cambridge, Massachusetts

London, England

( 2011 Massachusetts Institute of Technology

All rights reserved. No part of this book may be reproduced in any form by any electronic or mechanical

means (including photocopying, recording, or information storage and retrieval) without permission in

writing from the publisher.

For information about quantity discounts, email [email protected].

Set in Stone Serif and Stone Sans on 3B2 by Asco Typesetters, Hong Kong. Printed and bound in the

United States of America.

Library of Congress Cataloging-in-Publication Data

The audio programming book / edited by Richard Boulanger and Victor Lazzarini; foreword by Max

Mathews.

p. cm.

Includes bibliographical references and index.

ISBN 978-0-262-01446-5 (hardcover : alk. paper) 1. Computer sound processing. 2. Signal processing—

Digital techniques. 3. Music—Computer programs. I. Boulanger, Richard Charles, 1956–. II. Lazzarini,

Victor, 1969–.

ML74.3.A93 2011

006.5—dc22 2010001731

10 9 8 7 6 5 4 3 2 1

This book is humbly dedicated to our teachers, mentors, and friends Max V. Mathews,

F. Richard Moore, and Barry Vercoe. They paved the way and they showed the way. They

were great explorers who freely and passionately shared their discoveries, their treasures—

their source code. Moreover, they invited every one of us to join them on the journey, to fol￾low their example, and to find ways to become a part of their great adventure and to build

upon the solid foundation that they laid down for us. All the contributors to this book stand

on the shoulders of these three giants of computer music. It is our hope that the book will

help the next generation to fully appreciate the great gifts of Mathews (MUSIC V), Moore

(cmusic), and Vercoe (Csound), and that it will help them find their own unique and inspir￾ing way to take the world one step further on this extraordinary audio adventure.

Contents

Foreword by Max V. Mathews xi

Preface xiii

Acknowledgments xv

Introduction xxi

C Programming Basics

0 An Overview of the C Language with Some Elements of CBB 3

Victor Lazzarini and Richard Boulanger

1 Programming in C 55

Richard Dobson

Audio Programming Basics

2 Audio Programming in C 185

Richard Dobson

3 Working with Audio Streams 329

Gabriel Maldonado

4 Introduction to Program Design 383

John ffitch

Audio Programming Essentials

5 Introduction to Digital Audio Signals 431

Victor Lazzarini

6 Time-Domain Audio Programming 463

Victor Lazzarini

Spectral Audio Programming

7 Spectral Audio Programming Basics: The DFT, the FFT, and Convolution 521

Victor Lazzarini

8 The STFT and Spectral Processing 539

Victor Lazzarini

9 Programming the Phase Vocoder 557

Victor Lazzarini

Programming Csound Opcodes

10 Understanding an Opcode in Csound 581

John ffitch

11 Spectral Opcodes 617

Victor Lazzarini

Algorithmic Synthesis and Music Programming

12 A Modular Synthesizer Simulation Program 629

Eric Lyon

13 Using C to Generate Scores 655

John ffitch

14 Modeling Orchestral Composition 677

Steven Yi

Appendixes

A Command-Line Tools Reference 697

Jonathan Bailey

B Debugging Software with the GNU Debugger 719

Jonathan Bailey

C Soundfiles, Soundfile Formats, and libsndfile 739

Victor Lazzarini

D An Introduction to Real-Time Audio IO with PortAudio 771

Victor Lazzarini

E MIDI Programming with PortMIDI 783

Victor Lazzarini

viii Contents

F Computer Architecture, Structures, and Languages 797

John ffitch

G Glossary 823

John ffitch with Richard Dobson, Victor Lazzarini, and Richard Boulanger

H An Audio Programmer’s Guide to Mathematical Expressions 855

John ffitch

Contents of the DVD 869

References 873

About the Authors 879

Index 881

ix Contents

Foreword

This is not just a book; it is an encyclopedia of mathematical and programming techniques

for audio signal processing. It is an encyclopedia focused on the future, but built upon the

massive foundations of past mathematical, signal processing, and programming sciences.

It is clearly written and easy to understand, by both human readers and computers. It

gives complete information, from the basic mathematics to the detailed programs needed

to make sound. It is the essential library, not only for computer musicians, but also for all

computer scientists, including those who work in the fields of communication and artificial

intelligence.

Today the dominant language in which to write programs is C (including Cþþ). A half￾century ago, sound synthesis programs for music were written in assembly language. The

resulting music had few voices and uninteresting timbres. Programs were tedious to write.

Block diagram compilers, including MUSIC V, cmusic, and Csound, greatly expanded the

musical possibilities by giving composers and sound designers tools with which to create

their own timbres from blocks of code—oscillators, envelopes, filters, mixers, etc. These

blocks performed tasks that electronic musicians were familiar with and that they could

understand. Block diagram compilers were a great step forward, but they imposed limits on

what the computer was allowed to do, in many ways because of their limited library of audio

modules or opcodes.

These limits have now been swept away. This book makes it practical to write a new C pro￾gram for each new piece of music. The composition is the C program. This is the great step

forward.

A half-century ago, computer sound processing was limited by the speed and expense of

existing hardware. Today those limits are gone. Affordable laptop computers are from

10,000 to 100,000 times as powerful as the roomful of equipment in a typical 1960s com￾puter center. And this book sweeps away the programming limits and makes practical musi￾cal use of the great power of laptops.

Early computers could not be used to perform a piece of music in real time—they took

many seconds to compute a single second of sound. But today real-time performance is pos￾sible, and practical real-time programming is a big part of this book. Thus, laptops can join

with chamber groups and orchestras and thereby add rich new timbres to the already beauti￾ful timbres of acoustic instruments.

What now is the musical challenge of the future? I believe it is our understanding of the

power and limitations of the human brain, and specifically discovering which sound waves,

sound patterns, timbres, and sequences humans recognize as beautiful and meaningful

music—and why. This book holds the key to copiously producing the software, sounds, and

music we need to truly and deeply explore these many and hidden dimensions of our

musical minds.

Max V. Mathews

xii Foreword

Preface

‘‘But how does an oscillator really work?’’ My 40-year journey to The Audio Programming Book

began with that question. Some of the answers came from Tom Piggott (my first electronic

music teacher, and the one who got me started with analog synthesizers—an EML200 and

an Arp2600).

More answers came from Alan R. Pearlman, founder and president of the ARP Synthesizer

Company, the man who commissioned my first symphony, Three Soundscapes for Synthesizers

and Orchestra.

Still more answers came from Dexter Morrill, who offered me a Visiting Composer’s Resi￾dency at Colgate University, where I made my first computer music. It took days back then,

but I rendered ‘‘Happy Birthday’’ in MUSIC 10 and played the rendered soundfile for my dad

over the phone on his birthday.

And more answers came from Bruce Pennycook, who was also in residence at Colgate. (We

would work through the night and end our sessions with breakfast at a local diner; I picked

his brain every spare minute; he taught me how to do stereo panning and gave me his sub￾bass oscillator instrument, LOW.)

I started to really answer the question in Barry Vercoe’s summer workshop at the Massa￾chusetts Institute of Technology, in which I learned music11. (I will never forget Barry filling

whiteboard after whiteboard, and revealing, one morning, that an oscillator consisted of a

phasor and a table.)

I made my way from MIT to the Center for Music Experiment at the University of Cali￾fornia at San Diego, where I learned about cmusic from Dick Moore, Gareth Loy, and Mark

Dolson. My first cmusic composition, Two Movements in C, featured a new trick that they

taught me to do with two oscillators: FM synthesis.

Life brought me back to Boston, and Barry invited me to continue my work at MIT’s new

Media Lab, where I got to explore and beta-test his new language, Csound. By his side, I was

able to further my understanding and to share some of the answers I had found along the

way through The Csound Book.

Overlapping with my time at the Computer Audio Research Lab in San Diego and the MIT

Media Lab, I got to know and work with Max V. Mathews. He invited me to work in his

studio at Bell Labs. (He would sleep in the recording booth there so that I could compose and

program.) We have worked together for more than 25 years now, touring, performing, lectur￾ing, and sometimes sailing. It was from him that I learned the programming language C. We

would spend days and days going over every single line of his Conductor and Improv pro￾grams, his Scanned Synthesis program, his PhaserFilters program, and his MUSIC V program.

(Imagine my surprise upon discovering that an oscillator is also an envelope generator, and

then the mind-bending fact that if you ‘‘scan’’ a ‘‘mechanically modeled’’ wavetable, an

oscillator can ‘‘be’’ a filter.)

But still, it took John ffitch, Richard Dobson, Gabriel Maldonado, and Victor Lazzarini to

teach me to actually ‘‘program’’ an oscillator—right here in The Audio Programming Book.

Yes, for me The Audio Programming Book answers my first question and many others. I

think you will agree that ffitch, Dobson, Maldonado, and Lazzarini are wonderful teachers,

and that the other contributors are their ‘‘young apprentices.’’ I hope the book will answer

all your questions and will raise new ones too.

Richard Boulanger

xiv Preface

Tải ngay đi em, còn do dự, trời tối mất!