next up previous contents index
Next: Wavelets Up: Float signals Previous: Related file (external) types   Contents   Index


Functions Summary

The following is a description of all the functions related to the Fsignal type. The list is in alphabetical order.

$ \bigcirc$Name


mw_alloc_fsignal - Allocate the array of values




$ \bigcirc$Summary


Fsignal mw_alloc_fsignal(signal,n)

Fsignal signal;

int n;




$ \bigcirc$Description


This function allocates the array values of a Fsignal structure previously created using mw_new_fsignal. The size of the signal is given by n, it corresponds to the number of samples.

Values can be addressed after this call, if the allocation successed. There is no default values.

Do not use this function if signal has already an allocated array: use the function mw_change_fsignal instead.

The function mw_alloc_fsignal returns NULL if not enough memory is available to allocate the array. Your code should check this return value to send an error message in the NULL case, and do appropriate statement.




$ \bigcirc$Example

Fsignal signal=NULL; /* Internal use: no Input neither Output of module */
int i;

/* Create a signal with 1000 samples */
if  ( ((signal = mw_new_fsignal()) == NULL) ||
      (mw_alloc_fsignal(signal,1000) == NULL) )
    mwerror(FATAL,1,"Not enough memory.\n");

/* Set the sample #i to the value i */
for (i=0;i<signal->size;i++) signal->values[i] = i;

$ \bigcirc$Name


mw_change_fsignal - Change the size of the array of values




$ \bigcirc$Summary


Fsignal mw_change_fsignal(signal, n)

Fsignal signal;

int n;




$ \bigcirc$Description


This function changes the memory allocation of the array values of a Fsignal structure, even if no previously memory allocation was done. The new size of the signal is given by n, it corresponds to the number of samples.

The function mw_change_fsignal can also create the structure if the input signal = NULL. Therefore, this function can replace both mw_new_fsignal and mw_alloc_fsignal. It is the recommended function to set signal size of input/output modules. Since the function can set the address of signal, the variable must be set to the return value of the function (See example below).

The function mw_change_fsignal returns NULL if not enough memory is available to allocate the array. Your code should check this return value to send an error message in the NULL case, and do appropriate statement.




$ \bigcirc$Example

Fsignal Output; /* Output of module */

/* Set the size of the signal to be 1000 */
Output = mw_change_fsignal(Output, 1000);
if (Output == NULL) mwerror(FATAL,1,"Not enough memory.\n");

$ \bigcirc$Name


mw_clear_fsignal - Clear all values




$ \bigcirc$Summary


void mw_clear_fsignal(signal, v)

Fsignal signal;

float v;




$ \bigcirc$Description


This function fills the fsignal signal with the value given by v: all samples will have the value v.




$ \bigcirc$Example

Fsignal signal; /* Output of module */

signal = mw_change_fsignal(signal, 1000);
if (signal == NULL) mwerror(FATAL,1,"Not enough memory.\n");
/* Set all samples to 0.0 */
mw_clear_fsignal(signal,0.0);

$ \bigcirc$Name


mw_copy_fsignal - Copy a signal into another one




$ \bigcirc$Summary


void mw_copy_fsignal(in, out)

Fsignal in,out;




$ \bigcirc$Description


This function copies the header and the content of the array values of the signal in into the corresponding fields of the signal out. The size of the two signals must be the same (this implies the out signal to be allocated).

The speed of this function depends to the C library implementation, but it is usually very fast (trying to do faster is a waste of time).




$ \bigcirc$Example

Fsignal G; /* Needed Input */
Fsignal F; /* Optional Output */

  if (F) {
    printf("F option is active: copy G in F\n");
    if ((F = mw_change_fsignal(F, G->size)) == NULL)
        mwerror(FATAL,1,"Not enough memory.\n");
    else mw_copy_fsignal(G, F);
   }
  else  printf("F option is not active\n");

$ \bigcirc$Name


mw_delete_fsignal - Deallocate the signal




$ \bigcirc$Summary


void mw_delete_fsignal(signal)

Fsignal signal;




$ \bigcirc$Description


This function deallocates the array values of a Fsignal structure previously allocated using mw_alloc_fsignal or mw_change_fsignal, and the structure itself.

You should set signal = NULL after this call since the address pointed by signal is no longer valid.




$ \bigcirc$Example

Fsignal signal=NULL; /* Internal use: no Input neither Output of module */

if  ( ((signal = mw_new_fsignal()) == NULL) ||
      (mw_alloc_fsignal(signal,1000) == NULL) )
    mwerror(FATAL,1,"Not enough memory.\n");
.
.
.
mw_delete_fsignal(signal);
signal = NULL;

$ \bigcirc$Name


mw_new_fsignal - Create a new Fsignal




$ \bigcirc$Summary


Fsignal mw_new_fsignal();




$ \bigcirc$Description


This function creates a new Fsignal structure with an empty array values. No samples can be addressed at this time. The array values should be allocated using the function mw_alloc_fsignal or mw_change_fsignal.

Do not use this function for input/output of modules, since the MegaWave2 Compiler already created the structure for you if you need it (See Volume one: ``MegaWave2 User's Guide''). Use instead the function mw_change_fsignal. Do not forget to deallocate the internal structures before the end of the module.

The function mw_new_fsignal returns NULL if not enough memory is available to create the structure. Your code should check this value to send an error message in the NULL case, and do appropriate statement.




$ \bigcirc$Example

Fsignal signal=NULL; /* Internal use: no Input neither Output of module */

if  ( ((signal = mw_new_fsignal()) == NULL) ||
      (mw_alloc_fsignal(signal,1000) == NULL) )
    mwerror(FATAL,1,"Not enough memory.\n");


next up previous contents index
Next: Wavelets Up: Float signals Previous: Related file (external) types   Contents   Index
mw 2004-05-05