[futurebasic] Re: [FB] Gunshots/QTMA Note Channel

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : February 2002 : Group Archive : Group : All Groups

From: Robert Covington <artlythere@...>
Date: Mon, 11 Feb 2002 06:30:13 -0500
This is the demo I have been testing with using v4.1.2 QT and OS 8.1 (no
sound of
any type) and QT5, OS 8.6, where I at least get a gunshot sound.

This prints out all the steps and results. Still no results as one would
expect, like one piano note. :) Even though that tone description is
getting loaded.

This example (in part) is from Page 35 of the Quicktime Musica Architecture
Inside Mac PDF.

If you make a new variable called nc2, and allocate a channel for that one,
you get the value 2. Which makes a little sense.

I get no errors here.  Anybody get any different results than silence with
Quicktime 4 and a Gunshot with Quicktime 5?

rc

'-----FB 3 Program-----------------
Library "QuickTimeLib"
#Define OpaqueNoteChannel as Ptr
#Define NoteAllocator as ComponentInstance
#Define NoteChannel As Ptr to OpaqueNoteChannel //(Non-public API)

_kSoftSynthComponentSubType = _"ss  "// Quicktime Soft Synth
_kNoteAllocatorComponentType = _"nota"

Begin Record ToneDescription
DIM synthesizerType  as Long
DIM synthesizerName  as Str31
DIM instrumentName   as Str31
DIM instrumentNumber as Long // BigEndian!
DIM gmNumber         as Long// BigEndian!
End Record

Begin Record NoteRequestInfo
DIM flags            AS Unsigned Int
DIM reserved         AS Unsigned Int
DIM polyphony        As short
DIM typicalPolyphony as Fixed
END Record

Begin Record D NoteRequest
DIM info as NoteRequestInfo   // in post-QuickTime 2.0 only
DIM tone as ToneDescription
End Record

// Beware ToolBox Line Wraps!
//
TOOLBOX FN NAPlayNote(NoteAllocator na,NoteChannel NoteChannel,long,long) =
ComponentResult `0x2F3C,0x000C,0x000D,0x7000,0xA82A
//
TOOLBOX FN NAStuffToneDescription(NoteAllocator na,long
gmNumber,ToneDescription  *td) = ComponentResult
`0x2F3C,0x0008,0x001B,0x7000,0xA82A
//
TOOLBOX FN NANewNoteChannel(NoteAllocator na,NoteRequest
*NoteRequest,NoteChannel *NoteChannel) = ComponentResult
`0x2F3C,0x0008,0x0004,0x7000,0xA82A
//
TOOLBOX FN NADisposeNoteChannel(NoteAllocator na,NoteChannel NoteChannel) =
ComponentResult `0x2F3C,0x0004,0x0005,0x7000,0xA82A
//
Library

/*
<Snip of large comment> The GM instruments are numbered 1 through
128, and the seven drum kits are numbered 16385 and higher.
*/


Local FN PlaySomeNotes
DIM @na         as NoteAllocator
DIM @nc         as NoteChannel
DIM @nr         as NoteRequest
DIM @thisError  as ComponentResult
DIM @t, i       as long

na = 0
nc = 0

// Open up the note allocator.
na = FN OpenDefaultComponent(_kNoteAllocatorComponentType, 0)

Long if na = 0
Print "No Note Allocator."
goto "goHome"
Xelse
Print "Got a Note Allocator."
END IF

// Fill out a NoteRequest using NAStuffToneDescription to help, and
// allocate a NoteChannel.
nr.info.flags      = 0
nr.info.reserved   = 0
nr.info.polyphony  = 2  // simultaneous tones
nr.info.typicalPolyphony = 0X00010000  // usually just one note
nr.tone.synthesizerType = _kSoftSynthComponentSubType
thisError = FN NAStuffToneDescription(na,1, @nr.tone)  // 1 is piano
Print  nr.tone.instrumentname
Print "Error Stuffing Tone Description? ";thisError
thisError = FN NANewNoteChannel(na, @nr, @nc)
Print "Error Creating New Note Channel? ";thisError
Print "Note Channel: ";nc
Long if (thisError OR nc = 0)
beep
goto "goHome"
END IF

/// Only plays Gunshot, though Tone Description shows load of Acoustic Piano?

thisError = FN NAPlayNote(na,nc, 60, 120)  // Note value of 60, velocity 120
print "Error on Play? ";thisError
Delay _sec
"goHome"
DIM err as ComponentResult
LONG IF  nc
err = FN NADisposeNoteChannel(na, nc)
Print "Error Disposing Note Channel? ";err
End IF
LONG if  na
err = FN CloseComponent( na)
END IF

END FN


Window 2

FN PlaySomeNotes

do
until FN Button




To change your subscription information or to be removed from the list,
please send email to mailto:MarkArnold@...