Maximum MIDI
Music Applications in C++
Paul Messick
  • August 1997
  • ISBN 9781884777448
  • 450 pages
  • printed in black & white

The author knows his stuff... he has hard industry experience.

Phil Sours, Cakewalk Music Software

Maximum MIDI shows you how to build world-class MIDI programs that can play music using computer sound cards or external keyboard instruments, teach music theory and technique, add music to games and allow musicians to record, edit, play and print compositions. Maximum MIDI gives programmers two ways to add MIDI to their programs. A flexible toolkit of C and C++ routines makes developing Windows 95 MIDI programs a breeze, and rock-solid algorithms and tons of field-tested source code allow advanced users to quickly "roll their own" — on any platform. Over a dozen example programs show how it's done.

Table of Contents detailed table of contents

preface

acknowledgments

author online

about the reader

guide to the book

1. MIDI and Windows 95

1.1. What is MIDI, Anyway?

1.2. Simple Connections

1.3. Why Not Use the MCI Sequencer or Streams?

1.4. The Windows MIDI Connection

1.5. The MaxMidi ToolKit

1.6. Rolling Your Own

2. The Musical Instrument Digital Interface

2.1. Overview

2.2. Get the Spec

2.3. The MIDI Protocol

2.4. Channel Voice Messages

2.4.1. Note On/Note Off

2.4.2. Aftertouch

2.4.3. Control Change

2.4.4. Program Change

2.4.5. Pitch Bend

2.5. Channel Mode Messages

2.6. System Messages

2.7. System Real-Time Messages

2.8. System Exclusive Messages

2.9. MIDI Time Code and SMPTE

2.10. General MIDI

2.10.1. The General MIDI Mode

2.10.2. General MIDI Requirements

2.10.3. The GM Sound Set

2.10.4. The Percussion Map

2.11. MIDI Evolution

3. Using MIDI in Windows

3.1. Organization of the ToolKit

3.2. Windows and DLLs

3.3. Windows 95 and the Win16Mutex

3.4. Timers and Windows 95

3.5. Low-Level MMSYSTEM MIDI Functions

3.5.1. MIDI Input Functions

3.5.2. MIDI Output Functions

3.6. Putting MIDI to Use

4. Sending MIDI

4.1. It’s An Event

4.2. Devices and Drivers

4.3. Identifying Devices

4.4. Initializing the MaxMidi System

4.5. Opening the MIDI Output Device

4.6. Sending An Event

4.7. Closing the MIDI Output

4.8. Other Useful MIDI Output Functions

4.9. Inside MIDI Output

4.9.1. Callbacks and Fixed Code Segments

4.9.2. MIDI Output Data Flow

5. Receiving MIDI

5.1. Opening and Using MIDI Input

5.2. Opening in Greater Detail

5.3. Controlling MIDI Input

5.4. The Input Queue

5.5. Closing the MIDI Input

5.6. Inside MIDI Input

5.6.1. MIDI Input Data Flow

6. System Exclusive Messages

6.1. One Stream — Handling Short and Long Messages

6.2. Sending and Receiving Sysexes

6.3. Long Messages and Buffers

6.4. MIDI Headers and Buffers

6.5. MIDI Input Data Flow Changes

6.6. MIDI Output Data Flow Changes

7. Keeping Time

7.1. Timestamps

7.2. Of Ticks and Tempo

7.3. Resolution and Accuracy

7.4. Generating Ticks

7.5. Processing Timestamps

7.6. Inside the Tick Generator

7.7. MIDI Time Code Synchronization

7.8. Starting SMPTE/MTC Synchronization

7.9. Chasing SMPTE/MTC

7.10. MIDI Timing Clock Synchronization

7.11. Chasing MIDI Sync

8. MaxMidi Synchronization

8.1. Using the Sync Functions

8.2. Playing Back in Time

8.3. Recording

8.4. Sync Data Flow

8.4.1. MIDI Input Data Flow Changes

8.4.2. MIDI Output Data Flow Changes

9. I Want My C++

9.1. Microsoft Visual C++ and the Microsoft Foundation Classes

9.1.1. Encapsulating the DLL in C++ Classes

9.2. The CMaxMidiIn Class

9.3. The CMaxMidiOut Class

9.4. The CMaxMidiSync Class

9.5. Attaching the Sync Device

9.6. Tempo and Resolution

9.7. Summary

10. Using the ToolKit with Microsoft Visual C++

10.1. The Application Framework

10.2. Adding MIDI to MFC Applications

10.3. Compiler Configuration

10.4. Add the ToolKit Files

10.5. Use the ToolKit Classes

10.6. Receiving and Sending MIDI

10.7. Adding Device Menus

11. Handling Sysex Messages in C++

11.1. Receiving Sysex Messages

11.2. Sending Sysex Messages

11.3. Loading and Saving Sysex Files

12. A Simple Sequencer

12.1. Tracks

12.2. Recording a Track

12.3. Playing Back the Track

13. Standard MIDI Files

13.1. SMFs Use Chunks

13.2. Variable-Length Values

13.3. Format 0 and Format 1 Files

13.4. The SMF Header Chunk

13.5. Track Chunks

13.6. Meta Events

13.7. Reading an SMF in C

13.8. Writing an SMF in C

13.9. Other MaxMidi SMF Functions

13.10. The CMaxMidiSMF Class

13.11. Inside the MaxMidi DLL SMF Routines

14. Enhancing the Sequencer

14.1. Playing Multiple Tracks

14.2. The Multitrack Sequencer Revealed

14.3. Writing a Standard MIDI File

14.4. Reading a Standard MIDI File

15. Go Forth and Write

15.1. Use the Source

15.2. Expanding the MIDI Horizon

15.3. Building An Even Better ToolKit

Appendix A: The MIDI ToolKit APIs

A.1. MaxMidi Function Reference

A.2. MIDI Output Functions

A.3. MIDI Input Functions

A.4. Synchronization Functions

A.5. Standard MIDI File Functions

A.6. System Functions

A.7. Error Codes

A.8. MaxMidi Messages

A.9. MaxMidi Structures

A.10. MaxMidi C++ Classes

A.11. MIDI Input Class — CMaxMidiIn

A.12. MIDI Sync Class — CMaxMidiSync

A.13. MIDI Input Menu Class — CMidiInDeviceMenu

A.14. MIDI Output Menu Class — CMidiOutDeviceMenu

A.15. Track Class — CMaxMidiTrack

A.16. Standard MIDI File Class — CMaxMidiSMF

Appendix B: MaxMidi DLL Source Code

B.1. MaxMidi Header Files

B.1.1. MaxMidi.h

B.1.2. MxDll.h

B.2. MxMidi16 DLL Source

B.2.1. MidiIn.c

B.2.2. MidiOut.c

B.2.3. Sync.c

B.2.4. MxMidi.def

B.3. MxMidi32 DLL Source

B.3.1. MxMidi32.c

B.3.2. SMF.c

B.4. Thunk Script

Appendix C: MaxMidi C++ Classes Source Code

C.1. CMaxMidiIn

C.2. CMaxMidiOut

C.3. CMaxMidiSync

C.4. CMaxMidiTrack

C.5. CMaxMidiSMF

C.6. CMidiInDeviceMenu

C.7. CMidiOutDeviceMenu

Appendix D: MidiSpy, SxLib and MaxSeq Source Code

D.1. MidiSpy

D.2. MidiSpy App

D.3. MainFrm

D.4. MidiSpyDoc

D.5. MidiSpyView

D.6. MyMidiIn

D.7. SxLib

D.8. SxLib App

D.9. MainFrm

D.10. SxLibDoc

D.11. SxLibView

D.12. MyMidiIn

D.13. MyMidiOut

D.14. MaxSeq

D.15. MaxSeq App

D.16. MainFrm

D.17. MaxSeqDoc

D.18. MaxSeqView

D.19. MyMidiIn

D.20. MySync

D.21. NewTrackDialog

D.22. ResolutionDialog

D.23. TempoDialog

D.24. MaxMidi ToolKit License Agreement

glossary

index

guide to the CDROM

About the book

The Maximum MIDI Programmer's ToolKit now supports both Windows 95 and Windows NT. Popular demand, insomnia, and caffeine have finally convinced Paul to port the ToolKit to NT. Your copy of Maximum MIDI: Music Applications in C++ entitles you to download the updated 95/NT DLLs (including source code) from the Maximum MIDI website. The new code — and ToolKit support via the book's Author Online forum — is only available to owners of the book.

About the author

Paul Messick, a long-time MIDI user, hardware developer and programmer, was Director of Engineering for Music Quest, where he designed MIDI interfaces and wrote Windows device drivers. He has extensive experience in the music software industry writing MIDI programs for a wide range of clients. Paul maintains a Maximum Midi web page at http://www.maxmidi.com.


Buy
pBook $49.95 softbound print

FREE domestic shipping on three or more pBooks

It is the only book I know that really explains Windows MIDI ... I recommend it!

Bret Costin, Midiman

... the organization is excellent, proceeding in a natural progression from introductory material to Toolkit basics to useful examples and extensions.

David Rowe, Opcode Systems, Inc.