Title Banner

Previous Book Contents Book Index Next

Newton Developer Technical Information: Newton Programmer's Guide: 2.1 OS Addendum /
Chapter 7 - Sound


Summary of Sound

Constants

kDefaultDevice // 0x00. Default input or output device

kInternalSpeaker // 0x01. Internal speaker kInternalMic // 0x04. Internal microphone kLineOut // 0x08. Line out on the interconnect bus kLineIn // 0x10. Line in on the interconnect bus kSampleStandard // 0. Uncompressed 8-bit samples kSampleMuLaw // 1. 8-bit samples encoded by the muLaw compressor kSampleLinear // 6. Uncompressed 16-bit samples k8Bit // 8. Samples are 8 bits each k16Bit // 16. Samples are 16 bits each "TMuLawCodec" // MuLaw codec "TIMACodec" // IMA codec "TGSMCodec" // GSM codec "TDTMFCodec" // Synthesizer codec

Data Structures

Sound Frame

soundFrame := {

sndFrameType: symbol, // 'simpleSound or 'codec codecName: string, // codec identifier bufferCount: integer, // number of codec buffers bufferSize: integer, // bytes in each codec buffer samples: binary, // sound samples or synthesizer data samplingRate: realOrInteger, // sampling rate per second compressionType: integer, // encoding format of data compressionRatio: real, // ratio of samples to bytes dataType: integer, // sample size (8 or 16 bits) volume: realOrInteger, // volume level start: integer, // index of first sample to play count: integer, // number of samples to play loops: integer, // number of times to repeat sound Callback: func(state, result)..., // called when play/record finishes }

Sound Result Frame

soundResultFrame := {

sound: frame, // sound frame that was paused or stopped index: integer, // index into sample data where stopped }

User Configuration Variables

inputGain // default input gain used during recording

inputDevice // default input device used for recording outputDevice // default output device used for playback soundVolumeDb // current system sound volume, in decibels alarmVolumeDb // current system alarm volume, in decibels

Synthesized Sound Data Format

type 'DTMF' {

unsigned integer; /* Parameter block type. Set to 1 */ unsigned integer; /* Synthesis type (1-5) */ unsigned integer; /* Reserved set to 0 */ unsigned integer; /* Synth loop count */ unsigned integer = $$CountOf(DTMFTones); /* Number of tone blocks */ wide array DTMFTones { unsigned integer; /* frequency integer part */ unsigned integer; /* frequency fractional part */ unsigned integer; /* sustain amplitude */ unsigned integer; /* leading silence in ms */ unsigned integer; /* attack in ms */ unsigned integer; /* decay in ms */ unsigned integer; /* sustain in ms */ unsigned integer; /* release in ms */ unsigned integer; /* peak amplitude */ unsigned integer; /* trailing silence in ms */ }; };

soundRecorder Object

sr := GetRoot().soundRecorder;

sr := { fSoundFrameSlots: frame, // sound frame overrides for recording fInputGain: integer, // sets inputGain slot in the sound channel fInputDevice: integer, // sets inputDevice slot in the sound channel fOutputDevice: integer, // sets outputDevice slot in the sound channel fCallback: func(array)..., // returns sounds when recorder is closed OpenRecord: func(callback)..., // opens sound recorder for recording OpenPlay: func(soundFrame)..., // opens sound recorder for playing }

Protos

protoRecorderView

aProtoRecorderView := {

_proto: protoRecorderView, elapsedTime: integer, // seconds of recorded sound statusText: { SetState: func(oldState, newState, hasSound)..., // state changed } GetSounds: func()..., // gets array of sound frames }

protoSoundChannel

aProtoSoundChannel := {

_proto: protoSoundChannel, direction: symbol, // 'record or 'play outputDevice: integer, // output device identifier inputDevice: integer, // input device identifier inputGain: integer, // 0-255 or nil (default is used) inputBlockSize: integer, // VBO size in bytes, for recording Close: func()..., // closes open sound channel GetInputGain: func()..., // gets input gain setting GetVolume: func()..., // gets volume setting IsActive: func()..., // is channel active? IsOpen: func()..., // is channel open? IsPaused: func()..., // is channel paused? NewInputBlock: func(Callback)..., // creates new sound frame/VBO NewRecording: func()..., // creates new sound channel for recording Open: func()..., // opens channel Pause: func()..., // pauses channel Schedule: func(soundFrame)..., // schedules sound frame SetInputGain: func(gain)..., // sets input gain SetVolume: func(volume)..., // sets volume Start: func(async)..., // starts channel playing/recording Stop: func()..., // stops channel playing/recording }

protoSoundFrame

aProtoSoundFrame := {

_proto: protoSoundFrame, length: integer, // number of samples in samples slot GetPlayingTime: func()..., // returns playing time in seconds GetSampleCount: func()..., // returns number of samples GetSampleSize: func()..., // returns size of each sample in bytes GetSamplingRate: func()..., // returns sampling rate SetRecordingLength: func(numSamples, Callback)..., // sets VBO size }

Functions

GetRegisteredSound(symbol)

PlaySound(soundFrame) PlaySoundEffect(soundFrame, volume, type) RegSound(symbol, soundFrame) SoundList() UnRegSound(symbol)


Subtopics
Constants
Data Structures
Sound Frame
Sound Result Frame
User Configuration Variables
Synthesized Sound Data Format
soundRecorder Object
Protos
protoRecorderView
protoSoundChannel
protoSoundFrame
Functions

Previous Book Contents Book Index Next

© Apple Computer, Inc.
26 APR 1997



Navigation graphic, see text links

Main | Top of Section | What's New | Apple Computer, Inc. | Find It | Feedback | Help