[futurebasic] Re: [FB] Re: Sound Manager

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

From: Richard Goodman <bhomme@...>
Date: Thu, 31 Jan 2002 07:50:06 -0800
Thanks, Alain, for your usual clear explanation of the facts pertaining to
my query about  cmd  = song[index].

Since I posted my message, I did some experimenting and confirmed what you
wrote: I can't use [index] with a container. However, I found I can use
Mid$ to get the character from any position in the container, and then use
any of several methods to get the ASCII code. Interestingly, Mid$ works
with containers; I don't need to use Mid$$. In other words, one can extract
a Pascal string from a container and it isn't necessary to create a
subcontainer.

I now have Sebastian storing melodies as containers and at the user's
option, playing the melody by means of the Sound Tutor code as we modified
it. Instead of using Inkey to control the playing, I created a small
control window with Play, Pause, Resume, and Stop buttons. I am in the
process of implementing the buttons. The user is forced to click on the
Stop button even after the the melody has finished playing in order for the
program to continue. This is necessary in order to allow the program to
dispose of the resources and handles associated with the Sound Manager
properly.

>
>Richard Goodman wrote:
>>
>> While were on the topic of the Sound ManagerS
>>
>> The following statement occurs in Hommel's Sound Tutor program as modified
>> by Alain Pastor:
>>
>> cmd  = song[index]
>>
>> I am in the process of incorporating Hommel's code into Sebastian and
>> transforming it into a somwhat different form that is more compatible with
>> my approach.
>>
>> I have tried to understand the above statement by looking for something
>> similar in the reference manual. Here is what I think is going on:
>>
>> "cmd" is a variable that has been dimensioned as CHAR. I don't know what
>> CHAR stands for, but I believe that it is an ASCII number for a character,
>> e.g. 115 for the letter s. Is that correct?
>
>RiCHARd,
>
>CHAR is a synonym for BYTE (8 bits).
>
>
>>
>> "song" has been dimensioned as a STR255.
>
>A string can be seen as an array of bytes. Each item in that array
>can be accessed individually thanks to the bracket syntax that
>allows us to use an index indicating the position of the character.
>The first item in that array represents the length of the Pascal
>string (the number of chars currently used in the string). Thus,
>song[0] gives the number of characters contained in the string named
>song; song[1] gives the ASCII code of the first character in the
>string; and so forth.
>the following statement:
>cmd = song[1]
>is equivalent to:
>cmd = ASC(MID$(song,1,1))
>>
>> "index" is a short integer.
>>
>> What I think this statement does is to PEEK the character in the song
>> string at the position in the string determined by "index" and put the
>> ASCII code for that character in the variable "cmd".
>>
>right, except I would write PEEK the ASCII code of the character in
>the song... to make the things clearer.
>
>
>> Can someone tell me if my interpretation is correct?
>> If I am not correct, can someone interpret the statement for me?
>> If my interpretation is correct, can I use the same syntax with a container?
>>
>You get it right. But you can't use the bracket syntax with
>containers. Well, I have not even tried, but I doubt it would work.
>Instead, you still can use the enhanced MID$$ function to achieve
>the same goal.
>
>cmd = ASC(MID$$(song$$,1,1)
>
>> I am storing my melodies as containers rather than strings because they are
>> may be longer than 255 characters.
>>
>> In other words, if "song" were dimensioned as a CONTAINER would the
>> statement cmd  = song[index] still be valid?
>>
>> TIA for any help on this.
>>
>You're welcome.
>
>--
>
>Alain
>