O'Reilly logo

Signal Processing in C by Thomas B. Passin, Christopher E. Reid

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 5

A Choir of Bells

In this chapter, the simple bell program developed in Chapter 4 is built up into a bell choir capable of playing any score you care to type into an ordinary text file. Several scores that it can play are included on the companion disk.

The code examples of Chapter 4 are difficult to use in the more demanding project of this chapter. A whole new approach to writing these programs is needed. The old “monolithic” style, which uses global variables and built-in constants, must be abandoned. The first order of business is planning the project. Then, a modern, encapsulated programming style is developed to support the many bells needed in the bell choir.

5.1 PLANNING THE PROJECT

The bell choir will be driven by a musical score stored in a disk file. There are two basic events that must be handled by each bell: striking and muting. A bell may be muted at a specific time, allowed to ring until it is inaudible, or struck several times without any muting. An unmuted bell rings for a long time before becoming inaudible, but it will eventually stop sounding. The program should, therefore, check for active bells that are no longer loud enough to be heard and can, therefore, be inactivated to save computation time.

Two basic approaches are possible for storing all the required bells. First, an array of all bells that might be needed could be established before any music is produced. The whole array of bells would exist, even though only a few would be used at any one ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required