1. Bernie - mixedlib question

Hi

I'm trying to do this

--typedef struct {
--    USHORT  nFrame;                             /* envelope frame */          
--    USHORT  nValue;                             /* envelope value */          
--} AUDIOPOINT, *PAUDIOPOINT;

record("AUDIOPOINT",
        "nFrame : ushort : 1 " &
        "nValue : ushort : 1 ")

--/* audio envelope structure */
--typedef struct {
--    AUDIOPOINT aEnvelope[AUDIO_MAX_POINTS];     /* envelope points */         

--/* audio envelope structure */
--typedef struct {
--    AUDIOPOINT aEnvelope[AUDIO_MAX_POINTS];     /* envelope points */         

record("AUDIOENVELOPE",
        "aEnvelope : STRUCT : AUDIOPOINT" &         -- AUDIO_MAX_POINTS = 12

(heavily snipped)

However, I can't get my head round how to create a repeating structure
(aEnvelope) AUDIO_MAX_POINTS long (12) for the AUDIOENVELOPE record.

Any hints?

Cheers in advance

Chris


http://euallegro.wikispaces.com
http://members.aol.com/chriscrylex/euphoria.htm
http://uboard.proboards32.com/
http://members.aol.com/chriscrylex/EUSQLite/eusql.html

new topic     » topic index » view message » categorize

2. Re: Bernie - mixedlib question

Chris Burch wrote:
> 
> Hi
> 
> I'm trying to do this
> 
> --typedef struct {
> --    USHORT  nFrame;                             /* envelope frame */     
>     
> --    USHORT  nValue;                             /* envelope value */     
>     
> --} AUDIOPOINT, *PAUDIOPOINT;
> 
> record("AUDIOPOINT",
>         "nFrame : ushort : 1 " &
>         "nValue : ushort : 1 ")
> 
> --/* audio envelope structure */
> --typedef struct {
> --    AUDIOPOINT aEnvelope[AUDIO_MAX_POINTS];     /* envelope points */    
>     
> 
> --/* audio envelope structure */
> --typedef struct {
> --    AUDIOPOINT aEnvelope[AUDIO_MAX_POINTS];     /* envelope points */    
>     
> 
> record("AUDIOENVELOPE",
>         "aEnvelope : STRUCT : AUDIOPOINT" &         -- AUDIO_MAX_POINTS = 12
> 
> (heavily snipped)
> 
> However, I can't get my head round how to create a repeating structure
> (aEnvelope)
> AUDIO_MAX_POINTS long (12) for the AUDIOENVELOPE record.
> 

Chris:



constant
  AUDIO_MAX_POINTS = 12

record("AUDIOPOINT",
       "nFrame : ushort : 1 " &
       "nValue : ushort : 1 ")

-- This creates an Array of AUDIO_MAX_POINTS ( 12 ) structures.
-- The structures will be initialize to all zeros.
--
-- use putsArray and grabsArray to access the array.
--
atom aEnvelope

aEnvelope = sArray("AUDIOPOINT",AUDIO_MAX_POINTS)


You can do this same thing with any of my libraries.

Bernie

My files in archive:
WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API 

Can be downloaded here:
http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan

new topic     » goto parent     » topic index » view message » categorize

3. Re: Bernie - mixedlib question

Bernie Ryan wrote:
> 
> Chris Burch wrote:
> > 
> > Hi
> > 
> > I'm trying to do this
> > 
> > --typedef struct {
> > --    USHORT  nFrame;                             /* envelope frame */     
> >     
> > --    USHORT  nValue;                             /* envelope value */     
> >     
> > --} AUDIOPOINT, *PAUDIOPOINT;
> > 
> > record("AUDIOPOINT",
> >         "nFrame : ushort : 1 " &
> >         "nValue : ushort : 1 ")
> > 
> > --/* audio envelope structure */
> > --typedef struct {
> > --    AUDIOPOINT aEnvelope[AUDIO_MAX_POINTS];     /* envelope points */    
> >     
> > 
> > --/* audio envelope structure */
> > --typedef struct {
> > --    AUDIOPOINT aEnvelope[AUDIO_MAX_POINTS];     /* envelope points */    
> >     
> > 
> > record("AUDIOENVELOPE",
> >         "aEnvelope : STRUCT : AUDIOPOINT" &         -- AUDIO_MAX_POINTS = 12
> > 
> > (heavily snipped)
> > 
> > However, I can't get my head round how to create a repeating structure
> > (aEnvelope)
> > AUDIO_MAX_POINTS long (12) for the AUDIOENVELOPE record.
> > 
> 
> Chris:
> 
> 
> }}}
<eucode>
> constant
>   AUDIO_MAX_POINTS = 12
> 
> record("AUDIOPOINT",
>        "nFrame : ushort : 1 " &
>        "nValue : ushort : 1 ")
> 
> -- This creates an Array of AUDIO_MAX_POINTS ( 12 ) structures.
> -- The structures will be initialize to all zeros.
> --
> -- use putsArray and grabsArray to access the array.
> --
> atom aEnvelope
> 
> aEnvelope = sArray("AUDIOPOINT",AUDIO_MAX_POINTS)
> 
> </eucode>
{{{

> 
> You can do this same thing with any of my libraries.
> 
> Bernie
> 
> My files in archive:
> WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API 
> 
> Can be downloaded here:
> <a
> href="http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan">http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan</a>

That was quick!

but, the entire structure is

record("AUDIOENVELOPE",
        "aEnvelope : STRUCT : AUDIOPOINT " &         -- AUDIO_MAX_POINTS = 12
        "nPoints : uchar : 1 " &
        "nSustain : uchar : 1 " &
        "nLoopStart : uchar : 1 " &
        "nLoopEnd : uchar : 1 " &
        "wFlags : ushort : 1 " &
        "nSpeed : ushort : 1 " )

so how can I define aEnvelope to be an array of 12 AUDIOPOINTS ?

Chris




http://euallegro.wikispaces.com
http://members.aol.com/chriscrylex/euphoria.htm
http://uboard.proboards32.com/
http://members.aol.com/chriscrylex/EUSQLite/eusql.html

new topic     » goto parent     » topic index » view message » categorize

4. Re: Bernie - mixedlib question

Chris Burch wrote:
> 
> record("AUDIOENVELOPE",
>         "aEnvelope : STRUCT : AUDIOPOINT " &         -- AUDIO_MAX_POINTS =
> 12
>         "nPoints : uchar : 1 " &
>         "nSustain : uchar : 1 " &
>         "nLoopStart : uchar : 1 " &
>         "nLoopEnd : uchar : 1 " &
>         "wFlags : ushort : 1 " &
>         "nSpeed : ushort : 1 " )
> 
> so how can I define aEnvelope to be an array of 12 AUDIOPOINTS ?
> 

Chris:


constant
AUDIO_MAX_POINTS = 12
--
record("AUDIOPOINT",
  "nFrame : ushort : 1 " &
  "nValue : ushort : 1 ")
--
record("AUDIO_PARAMS",
  "nPoints : uchar : 1 " &
  "nSustain : uchar : 1 " &
  "nLoopStart : uchar : 1 " &
  "nLoopEnd : uchar : 1 " &
  "wFlags : ushort : 1 " &
  "nSpeed : ushort : 1 " )
--
atom aEnvelope, aEnvelope_params
--
aEnvelope =
allocate((sizeof("AUDIOPOINT")*AUDIO_MAX_POINTS)+sizeof("AUDIO_PARAMS"))
--
aEnvelope_params = aEnvelope+(sizeof("AUDIOPOINT")*AUDIO_MAX_POINTS)
--
AssociatePtr(aEnvelope_params,"AUDIO_PARAMS")
--
-- use putsArray and grabsArray to access the ARRAY PORTION
-- using aEnvelope pointer.
--
-- Example: putsArray(aEnvelope,2,"nValue",1000) -- nValue in second array
--
-- use put and grab to access LOWER PART using the aEnvelope_params pointer
--
-- Example: put(aEnvelope_params,"nSpeed",100)
--
-- USE  free_mem({aEnvelope,aEnvelope_params}) to free memory when your done.



Bernie

My files in archive:
WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API 

Can be downloaded here:
http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan

new topic     » goto parent     » topic index » view message » categorize

5. Re: Bernie - mixedlib question

Chris Burch wrote:
> 
> record("AUDIOENVELOPE",
>         "aEnvelope : STRUCT : AUDIOPOINT " &         -- AUDIO_MAX_POINTS =
> 12
>         "nPoints : uchar : 1 " &
>         "nSustain : uchar : 1 " &
>         "nLoopStart : uchar : 1 " &
>         "nLoopEnd : uchar : 1 " &
>         "wFlags : ushort : 1 " &
>         "nSpeed : ushort : 1 " )
> 
> so how can I define aEnvelope to be an array of 12 AUDIOPOINTS ?
> 

Chris:

constant
AUDIO_MAX_POINTS = 12
--
record("AUDIOPOINT",
  "nFrame : ushort : 1 " &
  "nValue : ushort : 1 ")
--
record("AUDIO_PARAMS",
  "nPoints : uchar : 1 " &
  "nSustain : uchar : 1 " &
  "nLoopStart : uchar : 1 " &
  "nLoopEnd : uchar : 1 " &
  "wFlags : ushort : 1 " &
  "nSpeed : ushort : 1 " )
--
atom aEnvelope, aEnvelope_params
--
aEnvelope =
allocate((sizeof("AUDIOPOINT")*AUDIO_MAX_POINTS)+sizeof("AUDIO_PARAMS"))
--
aEnvelope_params = aEnvelope+(sizeof("AUDIOPOINT")*AUDIO_MAX_POINTS)
AssociatePtr(aEnvelope_params,"AUDIO_PARAMS")
-- set the aEnvelope_params structure to all zeros.
clears(aEnvelope_params)
--
-- use putsArray and grabsArray to access the ARRAY PORTION
-- using aEnvelope pointer.
--
-- Example: putsArray(aEnvelope,2,"nValue",1000) -- nValue in second array
--
-- use put and grab to access LOWER PART using the aEnvelope_params pointer
--
-- Example: put(aEnvelope_params,"nSpeed",100)
--
-- Use free_mem({aEnvelope,aEnvelope_params}) to free up the memory 


Bernie

My files in archive:
WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API 

Can be downloaded here:
http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan

new topic     » goto parent     » topic index » view message » categorize

6. Re: Bernie - mixedlib question

Hi

Thanks Bernie, that's fantastic, you are a guru.

Chris

http://euallegro.wikispaces.com
http://members.aol.com/chriscrylex/euphoria.htm
http://uboard.proboards32.com/
http://members.aol.com/chriscrylex/EUSQLite/eusql.html

new topic     » goto parent     » topic index » view message » categorize

7. Re: Bernie - mixedlib question

Chris: 
     IGNORE THE LAST TWO POST THEY ARE INCORRECT ALL GET BACK
    WITH YOU WITH THE CORRECT LATER.
Bernie

My files in archive:
WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API 

Can be downloaded here:
http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan

new topic     » goto parent     » topic index » view message » categorize

8. Re: Bernie - mixedlib question

Chris:

constant
AUDIO_MAX_POINTS = 12
--
record("AUDIOPOINT",
  "nFrame : ushort : 1 " &
  "nValue : ushort : 1 ")
--
record("AUDIO_PARAMS",
  "nPoints : uchar : 1 " &
  "nSustain : uchar : 1 " &
  "nLoopStart : uchar : 1 " &
  "nLoopEnd : uchar : 1 " &
  "wFlags : ushort : 1 " &
  "nSpeed : ushort : 1 " )
--
atom etop, ebot, aEnvSize, aEnvelope, aEnvelope_params
--
aEnvSize = (sizeof("AUDIOPOINT")*AUDIO_MAX_POINTS)+sizeof("AUDIO_PARAMS")
--
aEnvelope = allocate(aEnvSize)
-- clear to all zeros.
mem_set(aEnvelope,0,aEnvSize)
--  associate aEnvelope pointer to top half.
AssociatePtr(aEnvelope,sArray("AUDIOPOINT",AUDIO_MAX_POINTS))
-- calculate pointer to lower half.
aEnvelope_params = aEnvelope+sizeof("AUDIOPOINT")*AUDIO_MAX_POINTS
-- associate aEnvelope_params pointer to lower half.
AssociatePtr(aEnvelope_params,"AUDIO_PARAMS")
--
-- use putsArray and grabsArray to access the ARRAY PORTION
-- using aEnvelope pointer.
--
-- Example: putsArray(aEnvelope,2,"nValue",1000) -- nValue in second array
--
-- use put and grab to access LOWER PART using the aEnvelope_params pointer
--
-- Example: put(aEnvelope_params,"nSpeed",100)
--
-- Free up memory when done with free_mem({aEnvelope_params,aEnvelope})
--


Bernie

My files in archive:
WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API 

Can be downloaded here:
http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan

new topic     » goto parent     » topic index » view message » categorize

9. Re: Bernie - mixedlib question

Thanks, thats brilliant

Chris

new topic     » goto parent     » topic index » view message » categorize

10. Re: Bernie - mixedlib question

Hi

Sorry Bernie, more questions

The AUDIOENVELOPE structure has now been created, in two contiguous parts, with
a pointer to the first part (an array of AUDIOPOINTS structures), and a pointer
to the second part (the new AUDIO_PARAMS record).

Now I have (including the original c structure)

--/* audio patch structure */
--typedef struct {
--    CHAR    szPatchName[32];                    /* patch name */
--    UCHAR   aSampleNumber[AUDIO_MAX_NOTES];     /* multi-sample table */
--    USHORT  nSamples;                           /* number of samples */
--    UCHAR   nVibratoType;                       /* vibrato type */
--    UCHAR   nVibratoSweep;                      /* vibrato sweep */
--    UCHAR   nVibratoDepth;                      /* vibrato depth */
--    UCHAR   nVibratoRate;                       /* vibrato rate */
--    USHORT  nVolumeFadeout;                     /* volume fadeout */
--    AUDIOENVELOPE Volume;                       /* volume envelope */
--    AUDIOENVELOPE Panning;                      /* panning envelope */
--    PAUDIOSAMPLE aSampleTable;                  /* sample table */
--} AUDIOPATCH, *PAUDIOPATCH;

record("AUDIOPATCH",
        "szPatchName : char : 32 " &
        "aSampleNumber : uchar : 96 " &         --AUDIO_MAX_NOTES
        "nSamples : ushort : 1 " &
        "nVibratoType : uchar : 1 " &
        "nVibratoSweep : uchar : 1 " &
        "nVibratoDepth : uchar : 1 " &
        "nVibratoRate : uchar : 1 " &
        "nVolumeFadeout : ushort : 1 " &
        "Volume : STRUCT : AUDIOENVELOPE " &
        "Panning : STRUCT : AUDIOENVELOPE " &
"aSampleTable : pointer : 1 " )        --careful here - its actually
        specified a pointer to a structure!
--the handle to a created
                                                AUDIOSAMPLE structure?


As you can see, it requires an AUDIENVELOPE structure, and the question is, 
do I have to build it by hand again, as you did before?

Cheers

Chris

new topic     » goto parent     » topic index » view message » categorize

11. Re: Bernie - mixedlib question

ChrisBurch2 wrote:
> 
> 
> Hi
> 
> Sorry Bernie, more questions
> 
> The AUDIOENVELOPE structure has now been created, in two contiguous parts,
> with
> a pointer to the first part (an array of AUDIOPOINTS structures), and a
> pointer
> to the second part (the new AUDIO_PARAMS record).
> 
> Now I have (including the original c structure)
> 
> }}}
<eucode>
> --/* audio patch structure */
> --typedef struct {
> --    CHAR    szPatchName[32];                    /* patch name */
> --    UCHAR   aSampleNumber[AUDIO_MAX_NOTES];     /* multi-sample table */
> --    USHORT  nSamples;                           /* number of samples */
> --    UCHAR   nVibratoType;                       /* vibrato type */
> --    UCHAR   nVibratoSweep;                      /* vibrato sweep */
> --    UCHAR   nVibratoDepth;                      /* vibrato depth */
> --    UCHAR   nVibratoRate;                       /* vibrato rate */
> --    USHORT  nVolumeFadeout;                     /* volume fadeout */
> --    AUDIOENVELOPE Volume;                       /* volume envelope */
> --    AUDIOENVELOPE Panning;                      /* panning envelope */
> --    PAUDIOSAMPLE aSampleTable;                  /* sample table */
> --} AUDIOPATCH, *PAUDIOPATCH;
> 
> record("AUDIOPATCH",
>         "szPatchName : char : 32 " &
>         "aSampleNumber : uchar : 96 " &         --AUDIO_MAX_NOTES
>         "nSamples : ushort : 1 " &
>         "nVibratoType : uchar : 1 " &
>         "nVibratoSweep : uchar : 1 " &
>         "nVibratoDepth : uchar : 1 " &
>         "nVibratoRate : uchar : 1 " &
>         "nVolumeFadeout : ushort : 1 " &
>         "Volume : STRUCT : AUDIOENVELOPE " &
>         "Panning : STRUCT : AUDIOENVELOPE " &
>         "aSampleTable : pointer : 1 " )        --careful here - its actually
>         specified a pointer to a structure!
>                                                 --the handle to a created
>                                                 AUDIOSAMPLE structure?
> </eucode>
{{{

> 

Chris:

This would be much easier.

constant
AUDIO_MAX_POINTS = 12
-- Create the point structures description.
sequence PTS PTS = {}
--
for i = 1 to AUDIO_MAX_POINTS do
  PTS &= sprintf("AP%d: STRUCT : AUDIOPOINT ",{i})
end for
--
record("AUDIOPOINT",
  "nFrame : ushort : 1 " &
  "nValue : ushort : 1 ")
--
record("AUDIOENVELOPE",PTS& -- point structures description.
  "nPoints : uchar : 1 " &
  "nSustain : uchar : 1 " &
  "nLoopStart : uchar : 1 " &
  "nLoopEnd : uchar : 1 " &
  "wFlags : ushort : 1 " &
  "nSpeed : ushort : 1 " )
--
record("AUDIOPATCH",
	"szPatchName : char : 32 " &
	"aSampleNumber : uchar : 96 " &
	"nSamples : ushort : 1 " &
	"nVibratoType : uchar : 1 " &
	"nVibratoSweep : uchar : 1 " &
	"nVibratoDepth : uchar : 1 " &
	"nVibratoRate : uchar : 1 " &
	"nVolumeFadeout : ushort : 1 " &
	"Volume : STRUCT : AUDIOENVELOPE " &
	"Panning : STRUCT : AUDIOENVELOPE " &
	"aSampleTable : pointer : 1 " )
-- Create a Pointer to an audio patch structure.
atom PAUDIOPATCH
-- Create the audio patch structure.
-- The complete structure will be initialized to all zeros.
PAUDIOPATCH = struc("AUDIOPATCH")
-- memory location of the created structure.
? PAUDIOPATCH
-- get size of entire structure
? sizeof(PAUDIOPATCH)
-- to access the structues.
put(PAUDIOPATCH,"Volume->AP3->nFrame",1000) -- 3rd volumne point structure.
? grab(PAUDIOPATCH,"Volume->AP3->nFrame")
put(PAUDIOPATCH,"Panning->AP7->nFrame",104) -- 7th panning point structure.
? grab(PAUDIOPATCH,"Panning->AP7->nFrame")
-- to access the other parts.
put(PAUDIOPATCH,"nVibratoDepth",5)
? grab(PAUDIOPATCH,"nVibratoDepth")
put(PAUDIOPATCH,"Volume->nSpeed",27)
? grab(PAUDIOPATCH,"Volume->nSpeed")
-- pause so we can see the above print
pause()
-- If want to clear the complete structure to all zeros.
--      clears(PAUDIOPATCH)
-- To free the memory that structure is using then.
--      free_mem(PAUDIOPATCH)
--


Bernie

My files in archive:
WMOTOR, XMOTOR, W32ENGIN, MIXEDLIB, EU_ENGIN, WIN32ERU, WIN32API 

Can be downloaded here:
http://www.rapideuphoria.com/cgi-bin/asearch.exu?dos=on&win=on&lnx=on&gen=on&keywords=bernie+ryan

new topic     » goto parent     » topic index » view message » categorize

12. Re: Bernie - mixedlib question

Hi

Of course it would, and thanks once again.

Chris

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu