// Text of project Piano written on 11/20/95 at 5:45 PM
// Beginning of text file Project Data
/*
**      Newton Developer Technical Support Sample Code
**
**      Bitchin' Piano, Shows loading and playing sounds and different pitches
**
**      by Todd Courtois, Newton Developer Technical Support
**
**      Copyright © 1993-1995 by Apple Computer, Inc.  All rights reserved.
**
**      You may incorporate this sample code into your applications without
**      restriction.  This sample code has been provided "AS IS" and the
**      responsibility for its operation is 100% yours.  You are not
**      permitted to modify and redistribute the source as "DTS Sample Code."
**      If you are going to re-distribute the source, we require that you
**      make it clear in the source that the code was descended from
**      Apple-provided sample code, but that you've made changes.
*/


rf := OpenResFileX(HOME & "resources");


// Read in the 11KHz sampled sound
hiSound := GetSound11("1760Hz22K") ;
loSound := GetSound11("880Hz22K");

// close up any resource files that were opened (VERY important)
CloseResFileX(rf);


// End of text file Project Data
// Beginning of file main.t

// Before Script for "mainView"
/*
**      Newton Developer Technical Support Sample Code
**
**      Bitchin' Piano, Shows loading and playing sounds and different pitches
**
**      by Todd Courtois, Newton Developer Technical Support
**
**      Copyright © 1993-1995 by Apple Computer, Inc.  All rights reserved.
**
**      You may incorporate this sample code into your applications without
**      restriction.  This sample code has been provided "AS IS" and the
**      responsibility for its operation is 100% yours.  You are not
**      permitted to modify and redistribute the source as "DTS Sample Code."
**      If you are going to re-distribute the source, we require that you
**      make it clear in the source that the code was descended from
**      Apple-provided sample code, but that you've made changes.
*/

mainView :=
    {viewBounds: {top: 2, left: 0, right: 234, bottom: 315},
     originalRate: 22026.43172,
     TweakSound:
       func(whichSound,theRate)
       begin
            whichSound.samplingRate := theRate;
            PlaySound(whichSound);
            whichSound.samplingRate := originalRate;
       end,
     viewSetupFormScript:
       func()
       begin
       
       
       	// resize to fit on all "small" newtons.
       	local b := GetAppParams();
       	constant kMaxWidth := 240;
       	constant kMaxHeight := 336;
       	self.viewBounds := RelBounds(b.appAreaLeft, b.appAreaTop,
       										  MIN(b.appAreaWidth, kMaxWidth),
       										  MIN(b.appAreaHeight, kMaxHeight));
       
       
            highSound := clone(highSound);
            lowSound := clone(lowSound);
       
       
            highSound.samplingRate := originalRate;
            lowSound.samplingRate := originalRate;
       end,
     viewFlags: 1,
     viewFormat: 336,
     declareSelf: 'base,
     lowSound: loSound
     ,
     highSound: hiSound,
     title: "Bitchin Piano",
     debug: "mainView",
     _proto: @157
    };

theKeyboard :=
    {
     keyDefinitions:
       [
       
        [keyVUnit, keyVUnit,
       				"1",  1,		      keyHUnit + keyVUnit + keyFramed + keyAutoHilite + keyRoundingUnit*3,
       				"2",  2.00000,		keyHUnit + keyVUnit + keyFramed + keyAutoHilite + keyRoundingUnit*3],
       
        [keyVUnit, keyVUnit,
       				"3",    1.05946,		keyHUnit + keyVUnit + keyFramed + keyAutoHilite + keyRoundingUnit*3,
       				"4",  2.11893,		keyHUnit + keyVUnit + keyFramed + keyAutoHilite + keyRoundingUnit*3],
       
        [keyVUnit, keyVUnit,
       				"5",  1.12246,		keyHUnit + keyVUnit + keyFramed + keyAutoHilite + keyRoundingUnit*3,
       				"6",  2.24492,		keyHUnit + keyVUnit + keyFramed + keyAutoHilite + keyRoundingUnit*3],
       
        [keyVUnit, keyVUnit,
       				"7",  1.18921,		keyHUnit + keyVUnit + keyFramed + keyAutoHilite + keyRoundingUnit*3,
       				"8",  2.37841,		keyHUnit + keyVUnit + keyFramed + keyAutoHilite + keyRoundingUnit*3],
       
        [keyVUnit, keyVUnit,
       				"9",   1.25992,		keyHUnit + keyVUnit + keyFramed + keyAutoHilite + keyRoundingUnit*3,
       				"10",  2.51984,		keyHUnit + keyVUnit + keyFramed + keyAutoHilite + keyRoundingUnit*3],
       
        [keyVUnit, keyVUnit,
       				"11",  1.33484,		keyHUnit + keyVUnit + keyFramed + keyAutoHilite + keyRoundingUnit*3,
       				"12",  2.66968,		keyHUnit + keyVUnit + keyFramed + keyAutoHilite + keyRoundingUnit*3],
       
        [keyVUnit, keyVUnit,
       				"13",  1.41421,		keyHUnit + keyVUnit + keyFramed + keyAutoHilite + keyRoundingUnit*3,
       				"14",  2.82843,		keyHUnit + keyVUnit + keyFramed + keyAutoHilite + keyRoundingUnit*3],
       
        [keyVUnit, keyVUnit,
       				"15",  1.49831,		keyHUnit + keyVUnit + keyFramed + keyAutoHilite + keyRoundingUnit*3,
       				"16",  2.99661,		keyHUnit + keyVUnit + keyFramed + keyAutoHilite + keyRoundingUnit*3],
       
        [keyVUnit, keyVUnit,
       				"17",  1.58740,		keyHUnit + keyVUnit + keyFramed + keyAutoHilite + keyRoundingUnit*3,
       				"18",  3.17480,		keyHUnit + keyVUnit + keyFramed + keyAutoHilite + keyRoundingUnit*3],
        
       [keyVUnit, keyVUnit,
       				"19",  1.68179,		keyHUnit + keyVUnit + keyFramed + keyAutoHilite + keyRoundingUnit*3,
       				"20",  3.36359,		keyHUnit + keyVUnit + keyFramed + keyAutoHilite + keyRoundingUnit*3],
       
        [keyVUnit, keyVUnit,
       				"21",  1.78180,		keyHUnit + keyVUnit + keyFramed + keyAutoHilite + keyRoundingUnit*3,
       				"22",  3.56359,		keyHUnit + keyVUnit + keyFramed + keyAutoHilite + keyRoundingUnit*3],
       
        [keyVUnit, keyVUnit,
       				"23", 1.88775,		keyHUnit + keyVUnit + keyFramed + keyAutoHilite + keyRoundingUnit*3,
       				"24",  3.77550,		keyHUnit + keyVUnit + keyFramed + keyAutoHilite + keyRoundingUnit*3],
       
        [keyVUnit, keyVUnit,
       				"25",  2.00000,		keyHUnit + keyVUnit + keyFramed + keyAutoHilite + keyRoundingUnit*3,
       				"26",  4.00000,		keyHUnit + keyVUnit + keyFramed + keyAutoHilite + keyRoundingUnit*3]
       
       
       
       	],
     viewBounds: {left: 40, top: 16, right: 200, bottom: 288},
     keyPressScript:
       func(key)
       begin
            if (key < 2) then 
            :TweakSound(highSound,originalRate/key)
       
            else
                :TweakSound(lowSound,originalRate/(key/2));
       
       end,
     debug: "theKeyboard",
     _proto: @188
    };
AddStepForm(mainView, theKeyboard);




constant |layout_main.t| := mainView;
// End of file main.t



