2010-03-05 20:21:13 +00:00
|
|
|
/*
|
|
|
|
* Asterisk -- An open source telephony toolkit.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010, Digium, Inc.
|
|
|
|
*
|
|
|
|
* David Vossel <dvossel@digium.com>
|
|
|
|
*
|
|
|
|
* See http://www.asterisk.org for more information about
|
|
|
|
* the Asterisk project. Please do not directly contact
|
|
|
|
* any of the maintainers of this project for assistance;
|
|
|
|
* the project provides a web site, mailing lists and IRC
|
|
|
|
* channels for your use.
|
|
|
|
*
|
|
|
|
* This program is free software, distributed under the terms of
|
|
|
|
* the GNU General Public License Version 2. See the LICENSE file
|
|
|
|
* at the top of the source tree.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*! \file
|
|
|
|
*
|
|
|
|
* \brief Pitch Shift Audio Effect
|
|
|
|
*
|
|
|
|
* \author David Vossel <dvossel@digium.com>
|
|
|
|
*
|
|
|
|
* \ingroup functions
|
|
|
|
*/
|
|
|
|
|
|
|
|
/************************* SMB FUNCTION LICENSE *********************************
|
|
|
|
*
|
|
|
|
* SYNOPSIS: Routine for doing pitch shifting while maintaining
|
|
|
|
* duration using the Short Time Fourier Transform.
|
|
|
|
*
|
|
|
|
* DESCRIPTION: The routine takes a pitchShift factor value which is between 0.5
|
|
|
|
* (one octave down) and 2. (one octave up). A value of exactly 1 does not change
|
|
|
|
* the pitch. num_samps_to_process tells the routine how many samples in indata[0...
|
|
|
|
* num_samps_to_process-1] should be pitch shifted and moved to outdata[0 ...
|
|
|
|
* num_samps_to_process-1]. The two buffers can be identical (ie. it can process the
|
|
|
|
* data in-place). fft_frame_size defines the FFT frame size used for the
|
|
|
|
* processing. Typical values are 1024, 2048 and 4096. It may be any value <=
|
|
|
|
* MAX_FRAME_LENGTH but it MUST be a power of 2. osamp is the STFT
|
|
|
|
* oversampling factor which also determines the overlap between adjacent STFT
|
|
|
|
* frames. It should at least be 4 for moderate scaling ratios. A value of 32 is
|
|
|
|
* recommended for best quality. sampleRate takes the sample rate for the signal
|
|
|
|
* in unit Hz, ie. 44100 for 44.1 kHz audio. The data passed to the routine in
|
|
|
|
* indata[] should be in the range [-1.0, 1.0), which is also the output range
|
|
|
|
* for the data, make sure you scale the data accordingly (for 16bit signed integers
|
|
|
|
* you would have to divide (and multiply) by 32768).
|
|
|
|
*
|
|
|
|
* COPYRIGHT 1999-2009 Stephan M. Bernsee <smb [AT] dspdimension [DOT] com>
|
|
|
|
*
|
|
|
|
* The Wide Open License (WOL)
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, distribute and sell this software and its
|
|
|
|
* documentation for any purpose is hereby granted without fee, provided that
|
|
|
|
* the above copyright notice and this license appear in all source copies.
|
|
|
|
* THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY OF
|
|
|
|
* ANY KIND. See http://www.dspguru.com/wol.htm for more information.
|
|
|
|
*
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2011-07-14 20:28:54 +00:00
|
|
|
/*** MODULEINFO
|
|
|
|
<support_level>extended</support_level>
|
|
|
|
***/
|
|
|
|
|
2010-03-05 20:21:13 +00:00
|
|
|
#include "asterisk.h"
|
|
|
|
|
|
|
|
#include "asterisk/module.h"
|
|
|
|
#include "asterisk/channel.h"
|
|
|
|
#include "asterisk/pbx.h"
|
|
|
|
#include "asterisk/utils.h"
|
|
|
|
#include "asterisk/audiohook.h"
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
/*** DOCUMENTATION
|
|
|
|
<function name="PITCH_SHIFT" language="en_US">
|
|
|
|
<synopsis>
|
|
|
|
Pitch shift both tx and rx audio streams on a channel.
|
|
|
|
</synopsis>
|
|
|
|
<syntax>
|
|
|
|
<parameter name="channel direction" required="true">
|
|
|
|
<para>Direction can be either <literal>rx</literal>, <literal>tx</literal>, or
|
|
|
|
<literal>both</literal>. The direction can either be set to a valid floating
|
|
|
|
point number between 0.1 and 4.0 or one of the enum values listed below. A value
|
|
|
|
of 1.0 has no effect. Greater than 1 raises the pitch. Lower than 1 lowers
|
|
|
|
the pitch.</para>
|
|
|
|
|
|
|
|
<para>The pitch amount can also be set by the following values</para>
|
|
|
|
<enumlist>
|
|
|
|
<enum name = "highest" />
|
|
|
|
<enum name = "higher" />
|
|
|
|
<enum name = "high" />
|
|
|
|
<enum name = "low" />
|
|
|
|
<enum name = "lower" />
|
|
|
|
<enum name = "lowest" />
|
2010-03-05 21:51:25 +00:00
|
|
|
</enumlist>
|
2010-03-05 20:21:13 +00:00
|
|
|
</parameter>
|
|
|
|
</syntax>
|
|
|
|
<description>
|
|
|
|
<para>Examples:</para>
|
|
|
|
<para>exten => 1,1,Set(PITCH_SHIFT(tx)=highest); raises pitch an octave </para>
|
|
|
|
<para>exten => 1,1,Set(PITCH_SHIFT(rx)=higher) ; raises pitch more </para>
|
|
|
|
<para>exten => 1,1,Set(PITCH_SHIFT(both)=high) ; raises pitch </para>
|
|
|
|
<para>exten => 1,1,Set(PITCH_SHIFT(rx)=low) ; lowers pitch </para>
|
|
|
|
<para>exten => 1,1,Set(PITCH_SHIFT(tx)=lower) ; lowers pitch more </para>
|
|
|
|
<para>exten => 1,1,Set(PITCH_SHIFT(both)=lowest) ; lowers pitch an octave </para>
|
|
|
|
|
|
|
|
<para>exten => 1,1,Set(PITCH_SHIFT(rx)=0.8) ; lowers pitch </para>
|
|
|
|
<para>exten => 1,1,Set(PITCH_SHIFT(tx)=1.5) ; raises pitch </para>
|
|
|
|
</description>
|
|
|
|
</function>
|
|
|
|
***/
|
|
|
|
|
2010-03-08 05:12:55 +00:00
|
|
|
#ifndef M_PI
|
2010-03-05 20:21:13 +00:00
|
|
|
#define M_PI 3.14159265358979323846
|
2010-03-08 05:12:55 +00:00
|
|
|
#endif
|
2010-03-05 20:21:13 +00:00
|
|
|
#define MAX_FRAME_LENGTH 256
|
|
|
|
|
|
|
|
#define HIGHEST 2
|
|
|
|
#define HIGHER 1.5
|
|
|
|
#define HIGH 1.25
|
|
|
|
#define LOW .85
|
|
|
|
#define LOWER .7
|
|
|
|
#define LOWEST .5
|
|
|
|
|
|
|
|
struct fft_data {
|
|
|
|
float in_fifo[MAX_FRAME_LENGTH];
|
|
|
|
float out_fifo[MAX_FRAME_LENGTH];
|
|
|
|
float fft_worksp[2*MAX_FRAME_LENGTH];
|
|
|
|
float last_phase[MAX_FRAME_LENGTH/2+1];
|
|
|
|
float sum_phase[MAX_FRAME_LENGTH/2+1];
|
|
|
|
float output_accum[2*MAX_FRAME_LENGTH];
|
|
|
|
float ana_freq[MAX_FRAME_LENGTH];
|
|
|
|
float ana_magn[MAX_FRAME_LENGTH];
|
|
|
|
float syn_freq[MAX_FRAME_LENGTH];
|
|
|
|
float sys_magn[MAX_FRAME_LENGTH];
|
|
|
|
long gRover;
|
|
|
|
float shift_amount;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct pitchshift_data {
|
|
|
|
struct ast_audiohook audiohook;
|
|
|
|
|
|
|
|
struct fft_data rx;
|
|
|
|
struct fft_data tx;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void smb_fft(float *fft_buffer, long fft_frame_size, long sign);
|
|
|
|
static void smb_pitch_shift(float pitchShift, long num_samps_to_process, long fft_frame_size, long osamp, float sample_rate, int16_t *indata, int16_t *outdata, struct fft_data *fft_data);
|
|
|
|
static int pitch_shift(struct ast_frame *f, float amount, struct fft_data *fft_data);
|
|
|
|
|
|
|
|
static void destroy_callback(void *data)
|
|
|
|
{
|
|
|
|
struct pitchshift_data *shift = data;
|
|
|
|
|
|
|
|
ast_audiohook_destroy(&shift->audiohook);
|
|
|
|
ast_free(shift);
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct ast_datastore_info pitchshift_datastore = {
|
|
|
|
.type = "pitchshift",
|
|
|
|
.destroy = destroy_callback
|
|
|
|
};
|
|
|
|
|
|
|
|
static int pitchshift_cb(struct ast_audiohook *audiohook, struct ast_channel *chan, struct ast_frame *f, enum ast_audiohook_direction direction)
|
|
|
|
{
|
|
|
|
struct ast_datastore *datastore = NULL;
|
|
|
|
struct pitchshift_data *shift = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
if (!f) {
|
|
|
|
return 0;
|
|
|
|
}
|
media formats: re-architect handling of media for performance improvements
In the old times media formats were represented using a bit field. This was
fast but had a few limitations.
1. Asterisk was limited in how many formats it could handle.
2. Formats, being a bit field, could not include any attribute information.
A format was strictly its type, e.g., "this is ulaw".
This was changed in Asterisk 10 (see
https://wiki.asterisk.org/wiki/display/AST/Media+Architecture+Proposal for
notes on that work) which led to the creation of the ast_format structure.
This structure allowed Asterisk to handle attributes and bundle information
with a format.
Additionally, ast_format_cap was created to act as a container for multiple
formats that, together, formed the capability of some entity. Another
mechanism was added to allow logic to be registered which performed format
attribute negotiation. Everywhere throughout the codebase Asterisk was
changed to use this strategy.
Unfortunately, in software, there is no free lunch. These new capabilities
came at a cost.
Performance analysis and profiling showed that we spend an inordinate
amount of time comparing, copying, and generally manipulating formats and
their related structures. Basic prototyping has shown that a reasonably
large performance improvement could be made in this area. This patch is the
result of that project, which overhauled the media format architecture
and its usage in Asterisk to improve performance.
Generally, the new philosophy for handling formats is as follows:
* The ast_format structure is reference counted. This removed a large amount
of the memory allocations and copying that was done in prior versions.
* In order to prevent race conditions while keeping things performant, the
ast_format structure is immutable by convention and lock-free. Violate this
tenet at your peril!
* Because formats are reference counted, codecs are also reference counted.
The Asterisk core generally provides built-in codecs and caches the
ast_format structures created to represent them. Generally, to prevent
inordinate amounts of module reference bumping, codecs and formats can be
added at run-time but cannot be removed.
* All compatibility with the bit field representation of codecs/formats has
been moved to a compatibility API. The primary user of this representation
is chan_iax2, which must continue to maintain its bit-field usage of formats
for interoperability concerns.
* When a format is negotiated with attributes, or when a format cannot be
represented by one of the cached formats, a new format object is created or
cloned from an existing format. That format may have the same codec
underlying it, but is a different format than a version of the format with
different attributes or without attributes.
* While formats are reference counted objects, the reference count maintained
on the format should be manipulated with care. Formats are generally cached
and will persist for the lifetime of Asterisk and do not explicitly need
to have their lifetime modified. An exception to this is when the user of a
format does not know where the format came from *and* the user may outlive
the provider of the format. This occurs, for example, when a format is read
from a channel: the channel may have a format with attributes (hence,
non-cached) and the user of the format may last longer than the channel (if
the reference to the channel is released prior to the format's reference).
For more information on this work, see the API design notes:
https://wiki.asterisk.org/wiki/display/AST/Media+Format+Rewrite
Finally, this work was the culmination of a large number of developer's
efforts. Extra thanks goes to Corey Farrell, who took on a large amount of the
work in the Asterisk core, chan_sip, and was an invaluable resource in peer
reviews throughout this project.
There were a substantial number of patches contributed during this work; the
following issues/patch names simply reflect some of the work (and will cause
the release scripts to give attribution to the individuals who work on them).
Reviews:
https://reviewboard.asterisk.org/r/3814
https://reviewboard.asterisk.org/r/3808
https://reviewboard.asterisk.org/r/3805
https://reviewboard.asterisk.org/r/3803
https://reviewboard.asterisk.org/r/3801
https://reviewboard.asterisk.org/r/3798
https://reviewboard.asterisk.org/r/3800
https://reviewboard.asterisk.org/r/3794
https://reviewboard.asterisk.org/r/3793
https://reviewboard.asterisk.org/r/3792
https://reviewboard.asterisk.org/r/3791
https://reviewboard.asterisk.org/r/3790
https://reviewboard.asterisk.org/r/3789
https://reviewboard.asterisk.org/r/3788
https://reviewboard.asterisk.org/r/3787
https://reviewboard.asterisk.org/r/3786
https://reviewboard.asterisk.org/r/3784
https://reviewboard.asterisk.org/r/3783
https://reviewboard.asterisk.org/r/3778
https://reviewboard.asterisk.org/r/3774
https://reviewboard.asterisk.org/r/3775
https://reviewboard.asterisk.org/r/3772
https://reviewboard.asterisk.org/r/3761
https://reviewboard.asterisk.org/r/3754
https://reviewboard.asterisk.org/r/3753
https://reviewboard.asterisk.org/r/3751
https://reviewboard.asterisk.org/r/3750
https://reviewboard.asterisk.org/r/3748
https://reviewboard.asterisk.org/r/3747
https://reviewboard.asterisk.org/r/3746
https://reviewboard.asterisk.org/r/3742
https://reviewboard.asterisk.org/r/3740
https://reviewboard.asterisk.org/r/3739
https://reviewboard.asterisk.org/r/3738
https://reviewboard.asterisk.org/r/3737
https://reviewboard.asterisk.org/r/3736
https://reviewboard.asterisk.org/r/3734
https://reviewboard.asterisk.org/r/3722
https://reviewboard.asterisk.org/r/3713
https://reviewboard.asterisk.org/r/3703
https://reviewboard.asterisk.org/r/3689
https://reviewboard.asterisk.org/r/3687
https://reviewboard.asterisk.org/r/3674
https://reviewboard.asterisk.org/r/3671
https://reviewboard.asterisk.org/r/3667
https://reviewboard.asterisk.org/r/3665
https://reviewboard.asterisk.org/r/3625
https://reviewboard.asterisk.org/r/3602
https://reviewboard.asterisk.org/r/3519
https://reviewboard.asterisk.org/r/3518
https://reviewboard.asterisk.org/r/3516
https://reviewboard.asterisk.org/r/3515
https://reviewboard.asterisk.org/r/3512
https://reviewboard.asterisk.org/r/3506
https://reviewboard.asterisk.org/r/3413
https://reviewboard.asterisk.org/r/3410
https://reviewboard.asterisk.org/r/3387
https://reviewboard.asterisk.org/r/3388
https://reviewboard.asterisk.org/r/3389
https://reviewboard.asterisk.org/r/3390
https://reviewboard.asterisk.org/r/3321
https://reviewboard.asterisk.org/r/3320
https://reviewboard.asterisk.org/r/3319
https://reviewboard.asterisk.org/r/3318
https://reviewboard.asterisk.org/r/3266
https://reviewboard.asterisk.org/r/3265
https://reviewboard.asterisk.org/r/3234
https://reviewboard.asterisk.org/r/3178
ASTERISK-23114 #close
Reported by: mjordan
media_formats_translation_core.diff uploaded by kharwell (License 6464)
rb3506.diff uploaded by mjordan (License 6283)
media_format_app_file.diff uploaded by kharwell (License 6464)
misc-2.diff uploaded by file (License 5000)
chan_mild-3.diff uploaded by file (License 5000)
chan_obscure.diff uploaded by file (License 5000)
jingle.diff uploaded by file (License 5000)
funcs.diff uploaded by file (License 5000)
formats.diff uploaded by file (License 5000)
core.diff uploaded by file (License 5000)
bridges.diff uploaded by file (License 5000)
mf-codecs-2.diff uploaded by file (License 5000)
mf-app_fax.diff uploaded by file (License 5000)
mf-apps-3.diff uploaded by file (License 5000)
media-formats-3.diff uploaded by file (License 5000)
ASTERISK-23715
rb3713.patch uploaded by coreyfarrell (License 5909)
rb3689.patch uploaded by mjordan (License 6283)
ASTERISK-23957
rb3722.patch uploaded by mjordan (License 6283)
mf-attributes-3.diff uploaded by file (License 5000)
ASTERISK-23958
Tested by: jrose
rb3822.patch uploaded by coreyfarrell (License 5909)
rb3800.patch uploaded by jrose (License 6182)
chan_sip.diff uploaded by mjordan (License 6283)
rb3747.patch uploaded by jrose (License 6182)
ASTERISK-23959 #close
Tested by: sgriepentrog, mjordan, coreyfarrell
sip_cleanup.diff uploaded by opticron (License 6273)
chan_sip_caps.diff uploaded by mjordan (License 6283)
rb3751.patch uploaded by coreyfarrell (License 5909)
chan_sip-3.diff uploaded by file (License 5000)
ASTERISK-23960 #close
Tested by: opticron
direct_media.diff uploaded by opticron (License 6273)
pjsip-direct-media.diff uploaded by file (License 5000)
format_cap_remove.diff uploaded by opticron (License 6273)
media_format_fixes.diff uploaded by opticron (License 6273)
chan_pjsip-2.diff uploaded by file (License 5000)
ASTERISK-23966 #close
Tested by: rmudgett
rb3803.patch uploaded by rmudgetti (License 5621)
chan_dahdi.diff uploaded by file (License 5000)
ASTERISK-24064 #close
Tested by: coreyfarrell, mjordan, opticron, file, rmudgett, sgriepentrog, jrose
rb3814.patch uploaded by rmudgett (License 5621)
moh_cleanup.diff uploaded by opticron (License 6273)
bridge_leak.diff uploaded by opticron (License 6273)
translate.diff uploaded by file (License 5000)
rb3795.patch uploaded by rmudgett (License 5621)
tls_fix.diff uploaded by mjordan (License 6283)
fax-mf-fix-2.diff uploaded by file (License 5000)
rtp_transfer_stuff uploaded by mjordan (License 6283)
rb3787.patch uploaded by rmudgett (License 5621)
media-formats-explicit-translate-format-3.diff uploaded by file (License 5000)
format_cache_case_fix.diff uploaded by opticron (License 6273)
rb3774.patch uploaded by rmudgett (License 5621)
rb3775.patch uploaded by rmudgett (License 5621)
rtp_engine_fix.diff uploaded by opticron (License 6273)
rtp_crash_fix.diff uploaded by opticron (License 6273)
rb3753.patch uploaded by mjordan (License 6283)
rb3750.patch uploaded by mjordan (License 6283)
rb3748.patch uploaded by rmudgett (License 5621)
media_format_fixes.diff uploaded by opticron (License 6273)
rb3740.patch uploaded by mjordan (License 6283)
rb3739.patch uploaded by mjordan (License 6283)
rb3734.patch uploaded by mjordan (License 6283)
rb3689.patch uploaded by mjordan (License 6283)
rb3674.patch uploaded by coreyfarrell (License 5909)
rb3671.patch uploaded by coreyfarrell (License 5909)
rb3667.patch uploaded by coreyfarrell (License 5909)
rb3665.patch uploaded by mjordan (License 6283)
rb3625.patch uploaded by coreyfarrell (License 5909)
rb3602.patch uploaded by coreyfarrell (License 5909)
format_compatibility-2.diff uploaded by file (License 5000)
core.diff uploaded by file (License 5000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@419044 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-07-20 22:06:33 +00:00
|
|
|
if (audiohook->status == AST_AUDIOHOOK_STATUS_DONE) {
|
2010-03-05 20:21:13 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(datastore = ast_channel_datastore_find(chan, &pitchshift_datastore, NULL))) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
shift = datastore->data;
|
|
|
|
|
|
|
|
if (direction == AST_AUDIOHOOK_DIRECTION_WRITE) {
|
|
|
|
pitch_shift(f, shift->tx.shift_amount, &shift->tx);
|
|
|
|
} else {
|
|
|
|
pitch_shift(f, shift->rx.shift_amount, &shift->rx);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int pitchshift_helper(struct ast_channel *chan, const char *cmd, char *data, const char *value)
|
|
|
|
{
|
|
|
|
struct ast_datastore *datastore = NULL;
|
|
|
|
struct pitchshift_data *shift = NULL;
|
|
|
|
int new = 0;
|
|
|
|
float amount = 0;
|
|
|
|
|
2014-03-27 19:21:44 +00:00
|
|
|
if (!chan) {
|
|
|
|
ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2010-03-05 20:21:13 +00:00
|
|
|
ast_channel_lock(chan);
|
|
|
|
if (!(datastore = ast_channel_datastore_find(chan, &pitchshift_datastore, NULL))) {
|
|
|
|
ast_channel_unlock(chan);
|
|
|
|
|
|
|
|
if (!(datastore = ast_datastore_alloc(&pitchshift_datastore, NULL))) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (!(shift = ast_calloc(1, sizeof(*shift)))) {
|
|
|
|
ast_datastore_free(datastore);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
Media Project Phase2: SILK 8khz-24khz, SLINEAR 8khz-192khz, SPEEX 32khz, hd audio ConfBridge, and other stuff
-Functional changes
1. Dynamic global format list build by codecs defined in codecs.conf
2. SILK 8khz, 12khz, 16khz, and 24khz with custom attributes defined in codecs.conf
3. Negotiation of SILK attributes in chan_sip.
4. SPEEX 32khz with translation
5. SLINEAR 8khz, 12khz, 24khz, 32khz, 44.1khz, 48khz, 96khz, 192khz with translation
using codec_resample.c
6. Various changes to RTP code required to properly handle the dynamic format list
and formats with attributes.
7. ConfBridge now dynamically jumps to the best possible sample rate. This allows
for conferences to take advantage of HD audio (Which sounds awesome)
8. Audiohooks are no longer limited to 8khz audio, and most effects have been
updated to take advantage of this such as Volume, DENOISE, PITCH_SHIFT.
9. codec_resample now uses its own code rather than depending on libresample.
-Organizational changes
Global format list is moved from frame.c to format.c
Various format specific functions moved from frame.c to format.c
Review: https://reviewboard.asterisk.org/r/1104/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@308582 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2011-02-22 23:04:49 +00:00
|
|
|
ast_audiohook_init(&shift->audiohook, AST_AUDIOHOOK_TYPE_MANIPULATE, "pitch_shift", AST_AUDIOHOOK_MANIPULATE_ALL_RATES);
|
2010-03-05 20:21:13 +00:00
|
|
|
shift->audiohook.manipulate_callback = pitchshift_cb;
|
|
|
|
datastore->data = shift;
|
|
|
|
new = 1;
|
|
|
|
} else {
|
|
|
|
ast_channel_unlock(chan);
|
|
|
|
shift = datastore->data;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!strcasecmp(value, "highest")) {
|
|
|
|
amount = HIGHEST;
|
|
|
|
} else if (!strcasecmp(value, "higher")) {
|
|
|
|
amount = HIGHER;
|
|
|
|
} else if (!strcasecmp(value, "high")) {
|
|
|
|
amount = HIGH;
|
|
|
|
} else if (!strcasecmp(value, "lowest")) {
|
|
|
|
amount = LOWEST;
|
|
|
|
} else if (!strcasecmp(value, "lower")) {
|
|
|
|
amount = LOWER;
|
|
|
|
} else if (!strcasecmp(value, "low")) {
|
|
|
|
amount = LOW;
|
|
|
|
} else {
|
|
|
|
if (!sscanf(value, "%30f", &amount) || (amount <= 0) || (amount > 4)) {
|
|
|
|
goto cleanup_error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!strcasecmp(data, "rx")) {
|
|
|
|
shift->rx.shift_amount = amount;
|
|
|
|
} else if (!strcasecmp(data, "tx")) {
|
|
|
|
shift->tx.shift_amount = amount;
|
|
|
|
} else if (!strcasecmp(data, "both")) {
|
|
|
|
shift->rx.shift_amount = amount;
|
|
|
|
shift->tx.shift_amount = amount;
|
|
|
|
} else {
|
|
|
|
goto cleanup_error;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (new) {
|
|
|
|
ast_channel_lock(chan);
|
|
|
|
ast_channel_datastore_add(chan, datastore);
|
|
|
|
ast_channel_unlock(chan);
|
|
|
|
ast_audiohook_attach(chan, &shift->audiohook);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
cleanup_error:
|
|
|
|
|
|
|
|
ast_log(LOG_ERROR, "Invalid argument provided to the %s function\n", cmd);
|
|
|
|
if (new) {
|
|
|
|
ast_datastore_free(datastore);
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void smb_fft(float *fft_buffer, long fft_frame_size, long sign)
|
|
|
|
{
|
|
|
|
float wr, wi, arg, *p1, *p2, temp;
|
|
|
|
float tr, ti, ur, ui, *p1r, *p1i, *p2r, *p2i;
|
|
|
|
long i, bitm, j, le, le2, k;
|
|
|
|
|
|
|
|
for (i = 2; i < 2 * fft_frame_size - 2; i += 2) {
|
|
|
|
for (bitm = 2, j = 0; bitm < 2 * fft_frame_size; bitm <<= 1) {
|
|
|
|
if (i & bitm) {
|
|
|
|
j++;
|
|
|
|
}
|
|
|
|
j <<= 1;
|
|
|
|
}
|
|
|
|
if (i < j) {
|
|
|
|
p1 = fft_buffer + i; p2 = fft_buffer + j;
|
|
|
|
temp = *p1; *(p1++) = *p2;
|
|
|
|
*(p2++) = temp; temp = *p1;
|
|
|
|
*p1 = *p2; *p2 = temp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (k = 0, le = 2; k < (long) (log(fft_frame_size) / log(2.) + .5); k++) {
|
|
|
|
le <<= 1;
|
|
|
|
le2 = le>>1;
|
|
|
|
ur = 1.0;
|
|
|
|
ui = 0.0;
|
|
|
|
arg = M_PI / (le2>>1);
|
|
|
|
wr = cos(arg);
|
|
|
|
wi = sign * sin(arg);
|
|
|
|
for (j = 0; j < le2; j += 2) {
|
|
|
|
p1r = fft_buffer+j; p1i = p1r + 1;
|
|
|
|
p2r = p1r + le2; p2i = p2r + 1;
|
|
|
|
for (i = j; i < 2 * fft_frame_size; i += le) {
|
|
|
|
tr = *p2r * ur - *p2i * ui;
|
|
|
|
ti = *p2r * ui + *p2i * ur;
|
|
|
|
*p2r = *p1r - tr; *p2i = *p1i - ti;
|
|
|
|
*p1r += tr; *p1i += ti;
|
|
|
|
p1r += le; p1i += le;
|
|
|
|
p2r += le; p2i += le;
|
|
|
|
}
|
|
|
|
tr = ur * wr - ui * wi;
|
|
|
|
ui = ur * wi + ui * wr;
|
|
|
|
ur = tr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void smb_pitch_shift(float pitchShift, long num_samps_to_process, long fft_frame_size, long osamp, float sample_rate, int16_t *indata, int16_t *outdata, struct fft_data *fft_data)
|
|
|
|
{
|
|
|
|
float *in_fifo = fft_data->in_fifo;
|
|
|
|
float *out_fifo = fft_data->out_fifo;
|
|
|
|
float *fft_worksp = fft_data->fft_worksp;
|
|
|
|
float *last_phase = fft_data->last_phase;
|
|
|
|
float *sum_phase = fft_data->sum_phase;
|
|
|
|
float *output_accum = fft_data->output_accum;
|
|
|
|
float *ana_freq = fft_data->ana_freq;
|
|
|
|
float *ana_magn = fft_data->ana_magn;
|
|
|
|
float *syn_freq = fft_data->syn_freq;
|
|
|
|
float *sys_magn = fft_data->sys_magn;
|
|
|
|
|
|
|
|
double magn, phase, tmp, window, real, imag;
|
|
|
|
double freq_per_bin, expct;
|
|
|
|
long i,k, qpd, index, in_fifo_latency, step_size, fft_frame_size2;
|
|
|
|
|
|
|
|
/* set up some handy variables */
|
|
|
|
fft_frame_size2 = fft_frame_size / 2;
|
|
|
|
step_size = fft_frame_size / osamp;
|
|
|
|
freq_per_bin = sample_rate / (double) fft_frame_size;
|
|
|
|
expct = 2. * M_PI * (double) step_size / (double) fft_frame_size;
|
|
|
|
in_fifo_latency = fft_frame_size-step_size;
|
|
|
|
|
|
|
|
if (fft_data->gRover == 0) {
|
|
|
|
fft_data->gRover = in_fifo_latency;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* main processing loop */
|
|
|
|
for (i = 0; i < num_samps_to_process; i++){
|
|
|
|
|
|
|
|
/* As long as we have not yet collected enough data just read in */
|
|
|
|
in_fifo[fft_data->gRover] = indata[i];
|
|
|
|
outdata[i] = out_fifo[fft_data->gRover - in_fifo_latency];
|
|
|
|
fft_data->gRover++;
|
|
|
|
|
|
|
|
/* now we have enough data for processing */
|
|
|
|
if (fft_data->gRover >= fft_frame_size) {
|
|
|
|
fft_data->gRover = in_fifo_latency;
|
|
|
|
|
|
|
|
/* do windowing and re,im interleave */
|
|
|
|
for (k = 0; k < fft_frame_size;k++) {
|
|
|
|
window = -.5 * cos(2. * M_PI * (double) k / (double) fft_frame_size) + .5;
|
|
|
|
fft_worksp[2*k] = in_fifo[k] * window;
|
|
|
|
fft_worksp[2*k+1] = 0.;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ***************** ANALYSIS ******************* */
|
|
|
|
/* do transform */
|
|
|
|
smb_fft(fft_worksp, fft_frame_size, -1);
|
|
|
|
|
|
|
|
/* this is the analysis step */
|
|
|
|
for (k = 0; k <= fft_frame_size2; k++) {
|
|
|
|
|
|
|
|
/* de-interlace FFT buffer */
|
|
|
|
real = fft_worksp[2*k];
|
|
|
|
imag = fft_worksp[2*k+1];
|
|
|
|
|
|
|
|
/* compute magnitude and phase */
|
|
|
|
magn = 2. * sqrt(real * real + imag * imag);
|
|
|
|
phase = atan2(imag, real);
|
|
|
|
|
|
|
|
/* compute phase difference */
|
|
|
|
tmp = phase - last_phase[k];
|
|
|
|
last_phase[k] = phase;
|
|
|
|
|
|
|
|
/* subtract expected phase difference */
|
|
|
|
tmp -= (double) k * expct;
|
|
|
|
|
|
|
|
/* map delta phase into +/- Pi interval */
|
|
|
|
qpd = tmp / M_PI;
|
|
|
|
if (qpd >= 0) {
|
|
|
|
qpd += qpd & 1;
|
|
|
|
} else {
|
|
|
|
qpd -= qpd & 1;
|
|
|
|
}
|
|
|
|
tmp -= M_PI * (double) qpd;
|
|
|
|
|
|
|
|
/* get deviation from bin frequency from the +/- Pi interval */
|
|
|
|
tmp = osamp * tmp / (2. * M_PI);
|
|
|
|
|
|
|
|
/* compute the k-th partials' true frequency */
|
|
|
|
tmp = (double) k * freq_per_bin + tmp * freq_per_bin;
|
|
|
|
|
|
|
|
/* store magnitude and true frequency in analysis arrays */
|
|
|
|
ana_magn[k] = magn;
|
|
|
|
ana_freq[k] = tmp;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ***************** PROCESSING ******************* */
|
|
|
|
/* this does the actual pitch shifting */
|
|
|
|
memset(sys_magn, 0, fft_frame_size * sizeof(float));
|
|
|
|
memset(syn_freq, 0, fft_frame_size * sizeof(float));
|
|
|
|
for (k = 0; k <= fft_frame_size2; k++) {
|
|
|
|
index = k * pitchShift;
|
|
|
|
if (index <= fft_frame_size2) {
|
|
|
|
sys_magn[index] += ana_magn[k];
|
|
|
|
syn_freq[index] = ana_freq[k] * pitchShift;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ***************** SYNTHESIS ******************* */
|
|
|
|
/* this is the synthesis step */
|
|
|
|
for (k = 0; k <= fft_frame_size2; k++) {
|
|
|
|
|
|
|
|
/* get magnitude and true frequency from synthesis arrays */
|
|
|
|
magn = sys_magn[k];
|
|
|
|
tmp = syn_freq[k];
|
|
|
|
|
|
|
|
/* subtract bin mid frequency */
|
|
|
|
tmp -= (double) k * freq_per_bin;
|
|
|
|
|
|
|
|
/* get bin deviation from freq deviation */
|
|
|
|
tmp /= freq_per_bin;
|
|
|
|
|
|
|
|
/* take osamp into account */
|
|
|
|
tmp = 2. * M_PI * tmp / osamp;
|
|
|
|
|
|
|
|
/* add the overlap phase advance back in */
|
|
|
|
tmp += (double) k * expct;
|
|
|
|
|
|
|
|
/* accumulate delta phase to get bin phase */
|
|
|
|
sum_phase[k] += tmp;
|
|
|
|
phase = sum_phase[k];
|
|
|
|
|
|
|
|
/* get real and imag part and re-interleave */
|
|
|
|
fft_worksp[2*k] = magn * cos(phase);
|
|
|
|
fft_worksp[2*k+1] = magn * sin(phase);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* zero negative frequencies */
|
|
|
|
for (k = fft_frame_size + 2; k < 2 * fft_frame_size; k++) {
|
|
|
|
fft_worksp[k] = 0.;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* do inverse transform */
|
|
|
|
smb_fft(fft_worksp, fft_frame_size, 1);
|
|
|
|
|
|
|
|
/* do windowing and add to output accumulator */
|
|
|
|
for (k = 0; k < fft_frame_size; k++) {
|
|
|
|
window = -.5 * cos(2. * M_PI * (double) k / (double) fft_frame_size) + .5;
|
|
|
|
output_accum[k] += 2. * window * fft_worksp[2*k] / (fft_frame_size2 * osamp);
|
|
|
|
}
|
|
|
|
for (k = 0; k < step_size; k++) {
|
|
|
|
out_fifo[k] = output_accum[k];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* shift accumulator */
|
|
|
|
memmove(output_accum, output_accum+step_size, fft_frame_size * sizeof(float));
|
|
|
|
|
|
|
|
/* move input FIFO */
|
|
|
|
for (k = 0; k < in_fifo_latency; k++) {
|
|
|
|
in_fifo[k] = in_fifo[k+step_size];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int pitch_shift(struct ast_frame *f, float amount, struct fft_data *fft)
|
|
|
|
{
|
|
|
|
int16_t *fun = (int16_t *) f->data.ptr;
|
|
|
|
int samples;
|
|
|
|
|
|
|
|
/* an amount of 1 has no effect */
|
|
|
|
if (!amount || amount == 1 || !fun || (f->samples % 32)) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
for (samples = 0; samples < f->samples; samples += 32) {
|
media formats: re-architect handling of media for performance improvements
In the old times media formats were represented using a bit field. This was
fast but had a few limitations.
1. Asterisk was limited in how many formats it could handle.
2. Formats, being a bit field, could not include any attribute information.
A format was strictly its type, e.g., "this is ulaw".
This was changed in Asterisk 10 (see
https://wiki.asterisk.org/wiki/display/AST/Media+Architecture+Proposal for
notes on that work) which led to the creation of the ast_format structure.
This structure allowed Asterisk to handle attributes and bundle information
with a format.
Additionally, ast_format_cap was created to act as a container for multiple
formats that, together, formed the capability of some entity. Another
mechanism was added to allow logic to be registered which performed format
attribute negotiation. Everywhere throughout the codebase Asterisk was
changed to use this strategy.
Unfortunately, in software, there is no free lunch. These new capabilities
came at a cost.
Performance analysis and profiling showed that we spend an inordinate
amount of time comparing, copying, and generally manipulating formats and
their related structures. Basic prototyping has shown that a reasonably
large performance improvement could be made in this area. This patch is the
result of that project, which overhauled the media format architecture
and its usage in Asterisk to improve performance.
Generally, the new philosophy for handling formats is as follows:
* The ast_format structure is reference counted. This removed a large amount
of the memory allocations and copying that was done in prior versions.
* In order to prevent race conditions while keeping things performant, the
ast_format structure is immutable by convention and lock-free. Violate this
tenet at your peril!
* Because formats are reference counted, codecs are also reference counted.
The Asterisk core generally provides built-in codecs and caches the
ast_format structures created to represent them. Generally, to prevent
inordinate amounts of module reference bumping, codecs and formats can be
added at run-time but cannot be removed.
* All compatibility with the bit field representation of codecs/formats has
been moved to a compatibility API. The primary user of this representation
is chan_iax2, which must continue to maintain its bit-field usage of formats
for interoperability concerns.
* When a format is negotiated with attributes, or when a format cannot be
represented by one of the cached formats, a new format object is created or
cloned from an existing format. That format may have the same codec
underlying it, but is a different format than a version of the format with
different attributes or without attributes.
* While formats are reference counted objects, the reference count maintained
on the format should be manipulated with care. Formats are generally cached
and will persist for the lifetime of Asterisk and do not explicitly need
to have their lifetime modified. An exception to this is when the user of a
format does not know where the format came from *and* the user may outlive
the provider of the format. This occurs, for example, when a format is read
from a channel: the channel may have a format with attributes (hence,
non-cached) and the user of the format may last longer than the channel (if
the reference to the channel is released prior to the format's reference).
For more information on this work, see the API design notes:
https://wiki.asterisk.org/wiki/display/AST/Media+Format+Rewrite
Finally, this work was the culmination of a large number of developer's
efforts. Extra thanks goes to Corey Farrell, who took on a large amount of the
work in the Asterisk core, chan_sip, and was an invaluable resource in peer
reviews throughout this project.
There were a substantial number of patches contributed during this work; the
following issues/patch names simply reflect some of the work (and will cause
the release scripts to give attribution to the individuals who work on them).
Reviews:
https://reviewboard.asterisk.org/r/3814
https://reviewboard.asterisk.org/r/3808
https://reviewboard.asterisk.org/r/3805
https://reviewboard.asterisk.org/r/3803
https://reviewboard.asterisk.org/r/3801
https://reviewboard.asterisk.org/r/3798
https://reviewboard.asterisk.org/r/3800
https://reviewboard.asterisk.org/r/3794
https://reviewboard.asterisk.org/r/3793
https://reviewboard.asterisk.org/r/3792
https://reviewboard.asterisk.org/r/3791
https://reviewboard.asterisk.org/r/3790
https://reviewboard.asterisk.org/r/3789
https://reviewboard.asterisk.org/r/3788
https://reviewboard.asterisk.org/r/3787
https://reviewboard.asterisk.org/r/3786
https://reviewboard.asterisk.org/r/3784
https://reviewboard.asterisk.org/r/3783
https://reviewboard.asterisk.org/r/3778
https://reviewboard.asterisk.org/r/3774
https://reviewboard.asterisk.org/r/3775
https://reviewboard.asterisk.org/r/3772
https://reviewboard.asterisk.org/r/3761
https://reviewboard.asterisk.org/r/3754
https://reviewboard.asterisk.org/r/3753
https://reviewboard.asterisk.org/r/3751
https://reviewboard.asterisk.org/r/3750
https://reviewboard.asterisk.org/r/3748
https://reviewboard.asterisk.org/r/3747
https://reviewboard.asterisk.org/r/3746
https://reviewboard.asterisk.org/r/3742
https://reviewboard.asterisk.org/r/3740
https://reviewboard.asterisk.org/r/3739
https://reviewboard.asterisk.org/r/3738
https://reviewboard.asterisk.org/r/3737
https://reviewboard.asterisk.org/r/3736
https://reviewboard.asterisk.org/r/3734
https://reviewboard.asterisk.org/r/3722
https://reviewboard.asterisk.org/r/3713
https://reviewboard.asterisk.org/r/3703
https://reviewboard.asterisk.org/r/3689
https://reviewboard.asterisk.org/r/3687
https://reviewboard.asterisk.org/r/3674
https://reviewboard.asterisk.org/r/3671
https://reviewboard.asterisk.org/r/3667
https://reviewboard.asterisk.org/r/3665
https://reviewboard.asterisk.org/r/3625
https://reviewboard.asterisk.org/r/3602
https://reviewboard.asterisk.org/r/3519
https://reviewboard.asterisk.org/r/3518
https://reviewboard.asterisk.org/r/3516
https://reviewboard.asterisk.org/r/3515
https://reviewboard.asterisk.org/r/3512
https://reviewboard.asterisk.org/r/3506
https://reviewboard.asterisk.org/r/3413
https://reviewboard.asterisk.org/r/3410
https://reviewboard.asterisk.org/r/3387
https://reviewboard.asterisk.org/r/3388
https://reviewboard.asterisk.org/r/3389
https://reviewboard.asterisk.org/r/3390
https://reviewboard.asterisk.org/r/3321
https://reviewboard.asterisk.org/r/3320
https://reviewboard.asterisk.org/r/3319
https://reviewboard.asterisk.org/r/3318
https://reviewboard.asterisk.org/r/3266
https://reviewboard.asterisk.org/r/3265
https://reviewboard.asterisk.org/r/3234
https://reviewboard.asterisk.org/r/3178
ASTERISK-23114 #close
Reported by: mjordan
media_formats_translation_core.diff uploaded by kharwell (License 6464)
rb3506.diff uploaded by mjordan (License 6283)
media_format_app_file.diff uploaded by kharwell (License 6464)
misc-2.diff uploaded by file (License 5000)
chan_mild-3.diff uploaded by file (License 5000)
chan_obscure.diff uploaded by file (License 5000)
jingle.diff uploaded by file (License 5000)
funcs.diff uploaded by file (License 5000)
formats.diff uploaded by file (License 5000)
core.diff uploaded by file (License 5000)
bridges.diff uploaded by file (License 5000)
mf-codecs-2.diff uploaded by file (License 5000)
mf-app_fax.diff uploaded by file (License 5000)
mf-apps-3.diff uploaded by file (License 5000)
media-formats-3.diff uploaded by file (License 5000)
ASTERISK-23715
rb3713.patch uploaded by coreyfarrell (License 5909)
rb3689.patch uploaded by mjordan (License 6283)
ASTERISK-23957
rb3722.patch uploaded by mjordan (License 6283)
mf-attributes-3.diff uploaded by file (License 5000)
ASTERISK-23958
Tested by: jrose
rb3822.patch uploaded by coreyfarrell (License 5909)
rb3800.patch uploaded by jrose (License 6182)
chan_sip.diff uploaded by mjordan (License 6283)
rb3747.patch uploaded by jrose (License 6182)
ASTERISK-23959 #close
Tested by: sgriepentrog, mjordan, coreyfarrell
sip_cleanup.diff uploaded by opticron (License 6273)
chan_sip_caps.diff uploaded by mjordan (License 6283)
rb3751.patch uploaded by coreyfarrell (License 5909)
chan_sip-3.diff uploaded by file (License 5000)
ASTERISK-23960 #close
Tested by: opticron
direct_media.diff uploaded by opticron (License 6273)
pjsip-direct-media.diff uploaded by file (License 5000)
format_cap_remove.diff uploaded by opticron (License 6273)
media_format_fixes.diff uploaded by opticron (License 6273)
chan_pjsip-2.diff uploaded by file (License 5000)
ASTERISK-23966 #close
Tested by: rmudgett
rb3803.patch uploaded by rmudgetti (License 5621)
chan_dahdi.diff uploaded by file (License 5000)
ASTERISK-24064 #close
Tested by: coreyfarrell, mjordan, opticron, file, rmudgett, sgriepentrog, jrose
rb3814.patch uploaded by rmudgett (License 5621)
moh_cleanup.diff uploaded by opticron (License 6273)
bridge_leak.diff uploaded by opticron (License 6273)
translate.diff uploaded by file (License 5000)
rb3795.patch uploaded by rmudgett (License 5621)
tls_fix.diff uploaded by mjordan (License 6283)
fax-mf-fix-2.diff uploaded by file (License 5000)
rtp_transfer_stuff uploaded by mjordan (License 6283)
rb3787.patch uploaded by rmudgett (License 5621)
media-formats-explicit-translate-format-3.diff uploaded by file (License 5000)
format_cache_case_fix.diff uploaded by opticron (License 6273)
rb3774.patch uploaded by rmudgett (License 5621)
rb3775.patch uploaded by rmudgett (License 5621)
rtp_engine_fix.diff uploaded by opticron (License 6273)
rtp_crash_fix.diff uploaded by opticron (License 6273)
rb3753.patch uploaded by mjordan (License 6283)
rb3750.patch uploaded by mjordan (License 6283)
rb3748.patch uploaded by rmudgett (License 5621)
media_format_fixes.diff uploaded by opticron (License 6273)
rb3740.patch uploaded by mjordan (License 6283)
rb3739.patch uploaded by mjordan (License 6283)
rb3734.patch uploaded by mjordan (License 6283)
rb3689.patch uploaded by mjordan (License 6283)
rb3674.patch uploaded by coreyfarrell (License 5909)
rb3671.patch uploaded by coreyfarrell (License 5909)
rb3667.patch uploaded by coreyfarrell (License 5909)
rb3665.patch uploaded by mjordan (License 6283)
rb3625.patch uploaded by coreyfarrell (License 5909)
rb3602.patch uploaded by coreyfarrell (License 5909)
format_compatibility-2.diff uploaded by file (License 5000)
core.diff uploaded by file (License 5000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@419044 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-07-20 22:06:33 +00:00
|
|
|
smb_pitch_shift(amount, 32, MAX_FRAME_LENGTH, 32, ast_format_get_sample_rate(f->subclass.format), fun+samples, fun+samples, fft);
|
2010-03-05 20:21:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct ast_custom_function pitch_shift_function = {
|
|
|
|
.name = "PITCH_SHIFT",
|
|
|
|
.write = pitchshift_helper,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int unload_module(void)
|
|
|
|
{
|
|
|
|
return ast_custom_function_unregister(&pitch_shift_function);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int load_module(void)
|
|
|
|
{
|
|
|
|
int res = ast_custom_function_register(&pitch_shift_function);
|
|
|
|
return res ? AST_MODULE_LOAD_DECLINE : AST_MODULE_LOAD_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2014-07-25 16:47:17 +00:00
|
|
|
AST_MODULE_INFO_STANDARD_EXTENDED(ASTERISK_GPL_KEY, "Audio Effects Dialplan Functions");
|