_____ | ||||
BEEP KEYBOARD | ||||
_____This is a sample in which the BEEP sound rings out when we press the keyboard on the screen. _____The "Note_On" function rings the BEEP sound. The argument is a numerical value that makes C3 (middle do) 60 (this is just made the same as MIDI; there is no deep reason). We calculate the frequency from the musical scale with the pow function. Because continuously ringing without limit is not possible with the BEEP statement, we have made the time 20 seconds. The "Note_Off" function stops the BEEP sound. ____When we start up, we first start up the "Release_Monitor" procedure. The "Release_Monitor" procedure waits with WAIT during sound production until the keyboard is released, and then once the keyboard is released, it performs a process that stops the sound generation. After we have started up the "Release_Monitor" procedure, we perform display in the order of white keys and then black keys (the black keys are displayed by overlaying on top of the white keys, and also at the time of pressing, the black keys are checked first). _____When the keyboard is pressed, the "Press_Processing" function starts up. If it's in the middle of sound production, it stops the sound production, sets the pressed keyboard number in the variable "Sounding," and then calls the "Note_On" function (by lining up in keyboard order event specification segments, we easily perform the calculations). With this, the BEEP sound rings, and then the "Press_Processing" terminates it. When the keyboard is released, the WAIT condition of the "Release_Monitor" procedure is established, and the sound production stops.
|
||||
292, 293 |
_____ | ||||
MIDI KEYBOARD | ||||
_____This is a sample in which a MIDI sound source connected to the RS-232C rings out when we press the keyboard on the screen. _____The "Note_On" function rings the BEEP sound. The argument is a numerical value that makes C3 (middle do) 60 (this is the same for the numerical values we transmit to MIDI). This transmits the Note_On message to the RS-232C. The "Note_Off" message similarly transmits the Note_Off message. ____When we start up, we first start up the "Release_Monitor" procedure. The "Release_Monitor" procedure waits with WAIT during sound production until the keyboard is released, and then once the keyboard is released, it performs a process that stops the sound generation. After we have started up the "Release_Monitor" procedure, we perform display in the order of white keys and then black keys (the black keys are displayed by overlaying on top of the white keys, and also at the time of pressing, the black keys are checked first). _____When the keyboard is pressed, the "Press_Processing" function starts up. If it's in the middle of sound production, it stops the sound production, sets the pressed keyboard number in the variable "Sounding," and then calls the "Note_On" function (by lining up in keyboard order event specification segments, we easily perform the calculations). With this, the BEEP sound rings, and then the "Press_Processing" terminates it. When the keyboard is released, the WAIT condition of the "Release_Monitor" procedure is established, and the sound production stops.
|
||||
294, 295 |
_____ | ||||
FALLING SIMULATION | ||||
_____This is a simulation in which a ball falls and is reflected on an inclined surface. Because it processes with integer values, there are also some unnatural points; for the time being it moves like that. _____The "Location_Calculation" function carries out falling processing in one-step increments. Even the reflection for a case where the ball collides with a wall is processed here. Calculation for the processing in which the ball collides with the inclined surface is complicated, but it can be derived from basic matrix calculations. _____When the program is started up, first it displays the segments, and then it starts up the "Ball_Falling" procedure. _____The "Ball_Falling" procedure carries out the simulation by continuously calling up the "Location_Calculation" function. It initializes the speed to 0, and after that it just repeatedly calls up the "Location_Calculation" function. _____The "Move_Ball" procedure starts up when the ball has been pressed. First, it terminates the "Ball_Falling" procedure (because the "Location_Calculation" is CALLed from the "Ball_Falling" procedure, it is necessary to terminate the "Ball_Falling" procedure to terminate the "Location_Calculation" function), and then it makes the pointer into the "Grip." We save the slippage between the ball's location and the pointer's location in "Slippage_X" and "Slippage_Y," and every time the pointer moves, the location of the ball also moves. This repeats until release, and once released, we return the pointer to its source and start up the "Ball_Falling" procedure.
|
||||
296, 297 |
_____ | ||||||
ANIMATION SWITCH | ||||||
_____This is a sample in which a switch display is made up in the form of animation and switches to a different scene when someone presses a switch. _____For animation processing, we utilize the SETSEG statement. We substitute temporarily with the SETSEG statement "anime region" segments in variable segment variables. Through this, anime region locations are set in the variable segment variables (the anime region segments are used only in showing locations; they are not displayed). _____Each thread of the anime processing changes by the SETSEG statement the variable segment, if the variable segment variable has been displayed. As for the SETSEG statement, because only the segment contents are changed with the location as is from the second time onward, the various figures of the animation can be laid out in free locations. Also, when we display with APPEAR, that segment comes to the forefront, but because the front-back relationship of the segments does not change with SETSEG, we can continue to place in the forefront a frame for press judgment use. _____For press processing, we have collected together in one procedure the processing of each screen (because this is substituted into a symbol variable, it has been declared in the SCRIPT statement at the beginning). This is because when we create a separate procedure for each switch, there is the possibility that in the middle of executing one procedure, another switch will be pressed and a procedure will start up. If we utilize the fact that only one thread can be executed at a time in the ACTION statement, and make it so that we enter inside a single procedure processing that would be troublesome if run simultaneously, then a script with high reliability can be created. _____The processing for when the screen switch is pressed is complicated at a glance, but this is because we made it so that we can create multiple screens with the smallest modifications possible, and after the script has branched in the beginning with the SWITCH statement, everything is made up completely the same. With the SWITCH statement, we divide the scene switching processing and the press processing. The scene switching processing just displays the necessary segments with the SCENE statement (it is also possible to add effects here). The press processing substitutes segments being pressed and corresponding procedures in symbol variables, and it loops until the button has been released. When the location of the pointer is inside a segment, it displays the segment being pressed; and when the location of the pointer comes outside of the segment, it erases the segment being pressed. When a segment being pressed has been displayed at the time the pointer has been released, the script calls up the corresponding procedure, and it switches the scene.
|
||||||
298-301 |
_____ | ||||
MIDI PLAYBACK | ||||
_____This is a sample in which we interpret a Standard MIDI File (SMF), which is a standard music file type, and then play it. However, it will not be of practical use for processing in a case where the tempo changes in multiple tracks, and there are deficiencies in fine error checking. Please treat it as a sample that handles files of a special type. _____We take in the SMF using the 1B MIDI player. After naming the just made real object "Target," we load it into the real object of the script. _____In PROLOGUE, we read in the file. First, we search for the record in which the beginning starts in the order 0xe7, 0xff. This is the specification fusen that is used in the MIDI player. Once it is found, it is judged as to whether it is a large segment or not, and then we hand over the beginning location of the main body to the "SMF_Analysis" procedure. _____The "SMF_Analysis" function, after initially checking whether it's really SMF or not, takes out the necessary information from the header portion. It seeks the number of tracks, and then starts up "Track_Processing" for each track. For this reason, the "Track_Processing" procedure is declared with MACTION. _____The "Track_Processing" procedure checks the information of each track, and then it takes out the length of the track. Because multiple tracks execute simultaneously with this procedure, variables are declared with LOCAL so that there will be no interference among the threads. Afterward, while waiting for a time, data are interpreted and output to the RS-232C. Since there is the possibility of outputting simultaneously from multiple threads, we output the individual commands in their entirety once, and thus we make it so that the outputs do not get mixed together. _____Furthermore, there is a line that begins with "#LOG;" this is what remains from when we first debugged using using the LOG statement. Once it became unnecessary, we made it invalid by attaching "#" at the beginning. When a problem occurs again, obtaining the necessary information becomes easy.
|
||||
Cho Kanji Samples' Note: The SMF real object has not been entered. For that reason, when you start up as is in MicroScript, an error will be displayed. Please take in the SMF using the 1B MIDI player, attach the name "Target" to the script real object, and then load it inside the script real object. | ||||
302-304 |
II Samples Section |
||||
SERIAL TRANSMISSION | ||||
_____This is a sample in which we read in only characters from a TAD-type real object created with the Basic Text Editor, convert the codes, and then transmit them to the RS-232C. _____With the function "Read_Real_Object," we read in a real object with the name "Input." We find a record in which the beginning is made up as 0xff80`0xffff, and then we go on to load into the character array of "Copy_Object" only the character segments inside that. Because things other than characters are also included inside TAD, we read the length of the segments and skip. _____Once we have read in the real object, we convert the character codes using the srconv function. Here, we are making it ASCII+EUC, but we can convert to the necessary character codes by changing the argument of the srconv function. _____Because the RSPUT statement can only transmit up to 512 bytes at a time, we are transmitting one byte each using the REPEAT statement.
|
||||
305, 306 |
The above contents of BTRON MicroScript Reference Manual were translated and loaded onto this Web page with the permission of Personal Media Corporation.
Copyright (c) 1997 Personal Media Corporation
Copyright (c) 2010 Sakamura Laboratory, University Museum, University of Tokyo