functions in AE.dll:

before any other function in this dll is used, AE_PrepareWaveFunctions(WavHdr() as WAVEHDR) must be called.  this publishes the pointers of gmt's WavHdr() to the dll.



SUB AE_GranulateTrack(BYVAL track AS LONG, BYVAL Env AD DWORD, Grain as GrainType)

splits the track in grains.
the grain type contains the folowing fields, all of wich must be filled in before calling the function:
   .length AS DWORD       : the length of one grain (in samples)
   .nr     AS DWORD       : the number of grains.  this can be computed with gmt's 
                            CalcNrOfGrains function 
                                Grain.nr = CalcNrOfGrains(track, Grain.length)
   .pArr   AS INTEGER PTR : a pointer to the array in wich the grains will be filled in. This array 
                            should be dimensioned so that there is sufficient space for all the 
                            grains, with 0 as lbound: 
                                DIM Arr(0 TO (Grain.nr * Grain.length) - 1)       

   track   is the number of the track that should be granulated.
   Env     determines which windowing function is used on the grains
                 2 for a hanning window
                 3 for a triangular window
                 4 for a betacurve window w/ params 3, 3


   


FUNCTION GranuSynthEx(GSD as GrainSynthDataType) AS LONG

the following fields of GSD should be filled in:
    .pGrain AS Grain PTR  : pointer to a Grain type that has been initialised before (see 
                             AE_GranulateTrack)
    .lOverl AS DWORD      : length of an array that contains overlapfactors, through wich the 
                            function proceeds in time, following linear curves. this factors 
                            determine the amount of grain overlapping. factors < 1 make grains 
                            overlap, factors > 1 leave holes between the grains. the lbound of this 
                            array  should be 0, so the length will be the ubound increased with one.
    .pOverl AS SINGLE PTR : the pointer to the first element of this array
    .duration AS DWORD    : duration of ms of the resulting track 

the function returns the number of the resulting track, or -1 if it failed (no free track).




FUNCTION GranuSynthStoch(GSD AS GrainSynthDataType) AS LONG

similar to GranuSynthEx, but here some additional fields of GSD should be filled in:
     .lLb AS DWORD
     .pLB AS DWORD PTR
     .lUB as DWORD
     .pUB as DWORD PTR
these refer to arrays containing the lbound resp. ubound in between wich grains are chosen at random.  here we make also linear transitions between the elements in the array.  lLb and lUB refer to the nr of elements in the arrays, wich should have lbound 0.  pLb and pUb are pointers to the first elements of the arrays. 
if the length of the lb and ub arrays is the same, and corresponding elements are equal, than you're shore that that grains is chosen.

so with arrays:
  lb(0 to 1) and ub(o to 1) 
  lb(0) = ub(0) = 0 
  and lb(1) = ub(1) = USD.@pGrain.nr - 1
you have the same results as with the GranuSynthEx function  



EOF