5.4 Partialsets
5.4.1 PmCreatePartialSet
Synopsis PmPartialSet PmCreatePartialSet (int max_index)
Creates and returns a new PartialSet.
max_index is the greatest partial index the new PartialSet can initially hold. Reallocation of an existing PartialSet can be done later.
Returns NULL if there is no available memory.
5.4.2 PmReallocPartialSet
Synopsis PmPartialSetPmReallocPartialSet (PmPartialSet aPS, int new_max_index)
Reallocates the input PartialSet aPS up to new_max_index.
Returns
If reallocation is successful, returns the same input PartialSet aPS with
reallocated size.
If reallocation fails, returns NULL and the size of aPS remains unchanged.
If aPS is NULL, returns a new PartialSet of size new_max_index,
or NULL if reallocation failed.
Most functions that operate on PartialSets provide for automatic reallocation.
Only the PartialSet's data access functions require the application programmer to
test allocation sizes before putting/getting data to/from a PartialSet.
5.4.3 PmFreePartialSet
Synopsis void PmFreePartialSet (PmPartialSet aPS)
Frees PartialSet aPS.
5.4.4 PmReadPartialSet
Synopsis int PmReadPartialSet (FILE *Stream, PmPartialSet aPS, int format_flag)
Reads one PartialSet aPS from the input Stream.
format_flag indicates the formatof the input stream.
Returns
1 if a PartialSet was read.
0 if EOF
-1 if there is no available memory to perform the operation.
5.4.5 PmWritePartialSet
Synopsis int PmWritePartialSet (FILE *Stream, PmPartialSet aPS, int format_flag)
Writes one PartialSet aPS to the output Stream.
format_flag indicates the formatof the output stream.
Returns
1 if a PartialSet was written.
-1 if there is no available memory to perform the operation.
5.4.6 PmCopyPartialSet
Synopsis void PmCopyPartialSet (PmPartialSet source, PmPartialSet destination)
Copies data from PartialSet source to PartialSet destination.
Returns 1 if data were successfully copied, -1 if there is no available memory to copy all source data.
5.4.7 PmDetectSpectralPeaks
Synopsis int PmDetectSpectralPeaks (float *complex_fft, PmPartialSet peaks,
float srate, int fft_size, int window_size)
Fills peaks with peaks detected in the spectrum complex_fft.
Index values of PartialSet peaks do not correspond to partial indexes. They identify a peak in the spectrum.
Vector complex_fft contains FFT real part at even locations, and FFT imaginary part at odd locations.
srate : sampling rate
fft_size : number of complex fft points
window_size : number of points of the signal window
Returns
[number of peaks] if detection is successful.
-1 if there is no available memory to perform the operation.
5.4.8 PmSeeve
Synopsis int PmSeeve (PmPartialSet peaks, PmPartialSet harms, float f0,
float band, float srate, int nbHarm)
Logical filtering of spectral peaks:
selects the peak of greatest amplitude in each harmonic band.
peaks : input spectral peaks. Could be the output of
PmDetectSpectralPeaks.
harms : output selected spectral peaks
f0 : fundamental frequency value
band : width of harmonic bands in pct (i.e. 100 means bandwidth = f0)
srate : sampling rate
nbHarm : max number of harmonics
Returns ?
5.4.9 PmPresentPartial
Synopsis int PmPresentPartial (PmPartialSet aPS, int index)
Returns 1 if partial index is present in PartialSet aPS, 0 otherwise.
5.4.10 PmUnwrapPhase
Synopsis float PmUnwrapPhase (float prev_freq, float next_freq,
float prev_phase, float next_phase, float dtime)
Returns the unwrapped phase variation of a variable-frequency sinusoid
between two times prev_time and next_time.
prev_freq : frequency at prev_time
next_freq : frequency at next_time
prev_phase : phase at prev_time
next_phase : phase at next_time
dtime : [next_time - prev_time]
5.4.11 PmWrapPhase
Synopsis float PmWrapPhase (float phase)
Wraps phase to the inverval [-PI;PI].
5.4.12 PmFreqTransp
Synopsis int PmFreqTransp (PmPartialSet nextOrig, PmPartialSet nextTransf,
PmPartialSet prevOrig, PmPartialSet prevTransf, float nextFactor,
float prevFactor)
Transposes frequencies of PartialSet nextOrig by factor
nextFactor and puts the result in nextTransf.
As phase evolution is taken into account, this algorithm needs past and
current data, defined at times prev_time and next_time respectively:
nextOrig : input non-transformed PartialSet at next_time.
nextTransf : output transformed PartialSet at next_time.
prevOrig : input non-transformed PartialSet at prev_time.
prevTransf : input transformed PartialSet at prev_time.
nextFactor : transposition factor at next_time.
prevFactor : transposition factor at prev_time.
If prevOrig or prevTransf are set to NULL, phase is
not considered (and prevFactor is not used). In this case,
phase values after frequency transposition are nonsense.
The algorithm still works if nextOrig is equal to nextTransf.
In this case, nextOrig non-transformed data is overwritten.
Returns
1 if transposition was successful.
-1 if there is no available memory to perform the operation.
5.4.13 PmIvarFreqTransp
Synopsis int PmIvarFreqTransp (PmPartialSet nextOrig, PmPartialSet nextTransf,
PmPartialSet prevOrig, PmPartialSet prevTransf, PmBreakPoint nextIvar,
float prevIvar)
Index-variable frequency transposition:
transposes frequencies of PartialSet nextOrig by a factor which
depends on the partial index.
Transposition factor is defined in a breakpoint function nextIvar
which contains points [index ; factor].
prevIvar is the breakpoint function which has been used at prev_time.
Other features are the same as for PmFreqTransp.
Returns
1 if transposition was successful.
-1 if there is no available memory to perform the operation.
5.4.14 PmFvarFreqTransp
Synopsis int PmFvarFreqTransp (PmPartialSet nextOrig, PmPartialSet nextTransf,
PmPartialSet prevOrig, PmPartialSet prevTransf, PmBreakPoint nextIvar,
float prevIvar)
Frequency-variable frequency transposition:
transposes frequencies of PartialSet nextOrig by a factor which
depends on the partial frequency.
Transposition factor is defined in a breakpoint function nextIvar
which contains points [frequency ; factor].
prevIvar is the breakpoint function which has been used at prev_time.
Other features are the same as for PmFreqTransp.
Returns
1 if transposition was successful.
-1 if there is no available memory to perform the operation.
5.4.15 PmTimeScaling
Synopsis int PmTimeScaling (PmPartialSet nextOrig, PmPartialSet nextTransf,
PmPartialSet prevOrig, PmPartialSet prevTransf,
float scaleFactor)
Scales time of PartialSet nextOrig according to factor
scaleFactor and puts the result in nextTransf.
The interval between nextTransf and prevTransf is calculated
as [next_time-prev_time] multiplied by factor scaleFactor.
Input and output PartialSets are the same as for PmFreqTransp.
If prevOrig or prevTransf are set to NULL:
Returns
1 if scaling was successful.
-1 if there is no available memory to perform the operation.
5.4.16 PmInterpPartialSet
Synopsis void PmInterpPartialSet (PmPartialSet left, PmPartialSet right,
PmPartialSet interp, int phase_flag)
Calculates an interpolated PartialSet interp between
PartialSets left and right.
The interpolation factor is calculated as
(interp_time - left_time) /
(right_time - left_time)
so time of PartialSet interp must be set before calling the function.
Amplitudes are linearly interpolated.
If phase_flag is set to 0, phases are not considered and frequencies
are linearly interpolated.
If phase_flag is different from 0, phases are assumed to be valid;
in this case phases and frequencies are interpolated using 3rd-degree and 2nd-degree
polynoms respectively.
Returns
1 if interpolation was successful.
-1 if there is no available memory to perform the operation.
5.4.17 PmSetSpectralEnv
Synopsis int PmSetSpectralEnv (PmPartialSet inPS,
PmPartialSet outPS, float *env, float scale_factor,
float srate, int env_size, int energy_flag)
Imposes the spectral envelope defined by env to inPS.
Amplitudes of partials in inPS are recalculated by interpolating
env at the corresponding partial frequencies.
The spectral envelope defined by env can be previously rescaled by
a scale_factor.
scale_factor > 1 stretches the envelope.
scale_factor < 1 compresses the envelope.
The result is placed in outPS, which can be eventually equal
to inPS.
env is a spectral envelope defined at env_size regularly
spaced points, corresponding to the frequency interval [0 - srate/2].
If energy_flag is different from 0, output and input energies are
equalized.
srate : sampling rate
Returns
1 if the operation was successful.
-1 if there is no available memory to perform the operation.
5.4.18 PmMultSpectralEnv
Synopsis int PmMultSpectralEnv (PmPartialSet inPS,
PmPartialSet outPS, float *env, float scale_factor,
float srate, int env_size, int energy_flag)
Same as PmSetSpectralEnv but multiplies amplitudes of partials
by the envelope instead of imposing it.
5.4.19 PmCopySubPartialSet
Synopsis int PmCopySubPartialSet (PmPartialSet inPS,
PmPartialSet outPS, int *subset_indexes, int nb_indexes)
Partials defined in inPS, and whose indexes are present
in subset_indexes, are copied to outPS.
outPS is reset to an empty PartialSet before copy is performed.
nb_indexes : number of elements of subset_indexes.
Returns
1 if the operation was successful.
-1 if there is no available memory to perform the operation.
5.4.20 PmMoveSubPartialSet
Synopsis int PmMoveSubPartialSet (PmPartialSet inPS,
PmPartialSet outPS, int *subset_indexes, int nb_indexes)
Partials defined in inPS, and whose indexes are present
in subset_indexes, are copied to outPS and
removed from inPS.
outPS is reset to an empty PartialSet before move is performed.
nb_indexes : number of elements of subset_indexes.
Returns
1 if the operation was successful,
-1 if there is no available memory to perform the operation.
5.4.21 PmAddSynt
Synopsis int PmAddSynt(PmPartialSetleft, PmPartialSetright,
float *outSig, int maxsize, int done, float srate, int phase_flag)
Performs additive synthesis in the interval between PartialSets left
and right, and puts the resulting signal in outSig. At most
maxsize samples are computed. Because the interval can be larger than
maxsize (the output buffer size), PmAddSynt must be called in a loop:
sig_done = 0;
do {
sig_size = PmAddSynt(leftPartialSet, rightPartialSet,
outSig, maxsize, sig_done, srate, phaseFlag);
sig_done += sig_size;
/* do something useful with the synthesized signal */
...
} while (sig_size == maxsize);
If phase_flag is set to 0, phases are not considered and frequencies
are linearly interpolated.
If phase_flag is different from 0, phases are assumed to be valid;
in this case phases and frequencies are interpolated using 3rd-degree and 2nd-degree
polynoms respectively.
srate : output sampling rate
Returns
the number of output samples actually computed if the
operation was successful.
-1 if there is no available memory
to perform the operation.
Formatted and maintained by Diemo Schwarz --- last change