use define SYSTEM_SAMPLERATE everywhere

git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@1051 8eb893ce-cfd4-0310-b710-fb5ebe64c474
sayer/1.4-spce2.6
Stefan Sayer 18 years ago
parent 7fb353e7ee
commit d6374b6c0e

@ -223,7 +223,7 @@ int AmAudioDelay::write(unsigned int user_ts, unsigned int size) {
}
int AmAudioDelay::read(unsigned int user_ts, unsigned int size) {
sarr.read((unsigned int) (user_ts - delay*8000.0), (short*) ((unsigned char*) samples), size >> 1);
sarr.read((unsigned int) (user_ts - delay*(float)SYSTEM_SAMPLERATE), (short*) ((unsigned char*) samples), size >> 1);
return size;
}

@ -39,8 +39,6 @@
#include <typeinfo>
#define SYSTEM_SAMPLERATE 8000 // fixme: sr per session
/** \brief structure to hold loaded codec instances */
struct CodecContainer
{
@ -140,7 +138,7 @@ AmAudioSimpleFormat::AmAudioSimpleFormat(int codec_id)
: AmAudioFormat(), codec_id(codec_id)
{
codec = getCodec();
rate = 8000;
rate = SYSTEM_SAMPLERATE;
channels = 1;
}
@ -275,6 +273,7 @@ AmAudio::~AmAudio()
}
void AmAudio::setFormat(AmAudioFormat* new_fmt) {
DBG("set format to %p --------------------------\n", new_fmt);
fmt.reset(new_fmt);
fmt->resetCodec();
}
@ -377,10 +376,10 @@ int AmAudio::encode(unsigned int size)
{
int s = size;
// if(!fmt.get()){
// DBG("no encode fmt\n");
// return 0;
// }
// if(!fmt.get()){
// DBG("no encode fmt\n");
// return 0;
// }
amci_codec_t* codec = fmt->getCodec();
long h_codec = fmt->getHCodec();

@ -47,6 +47,8 @@ using std::string;
#define PCM16_B2S(b) ((b) >> 1)
#define PCM16_S2B(s) ((s) << 1)
#define SYSTEM_SAMPLERATE 8000 // fixme: sr per session
class SdpPayload;
class CodecContainer;

@ -33,8 +33,8 @@
#define MAX_PACKETLENGTH_MS 30
#define MAX_BUF_SAMPLES 8000 * MAX_PACKETLENGTH_MS / 1000
#define DEFAULT_SAMPLE_RATE 8000 // eh...
#define MAX_BUF_SAMPLES SYSTEM_SAMPLERATE * MAX_PACKETLENGTH_MS / 1000
#define DEFAULT_SAMPLE_RATE SYSTEM_SAMPLERATE // eh...
/**
* \brief \ref AmAudio to mix in every n seconds a file

@ -462,7 +462,7 @@ AmSemsInbandDtmfDetector::AmSemsInbandDtmfDetector(AmKeyPressSink *keysink)
m_last(' '),
m_idx(0),
m_count(0),
SAMPLERATE(8000)
SAMPLERATE(SYSTEM_SAMPLERATE)
{
/* precalculate 2 * cos (2 PI k / N) */
for(unsigned i = 0; i < NELEMSOF(rel_cos2pik); i++) {

@ -29,11 +29,12 @@
#define _AmJitterBuffer_h_
#include "amci/amci.h"
#include "AmAudio.h"
#include "AmThread.h"
#include "SampleArray.h"
#define INITIAL_JITTER 640 // 80 miliseconds
#define MAX_JITTER 16000 // 2 seconds
#define INITIAL_JITTER 80 * SYSTEM_SAMPLERATE / 1000 // 80 miliseconds
#define MAX_JITTER 2 * SYSTEM_SAMPLERATE // 2 seconds
#define RESYNC_THRESHOLD 2
class Packet {

@ -26,6 +26,7 @@
*/
#include "AmMediaProcessor.h"
#include "AmSession.h"
#include "AmRtpStream.h"
#include <assert.h>
@ -212,7 +213,7 @@ void AmMediaProcessorThread::run()
events.processEvents();
processDtmfEvents();
ts += 80; // 10 ms
ts += 10 * SYSTEM_SAMPLERATE / 1000; // 10 ms
timeradd(&tick,&next_tick,&next_tick);
}
}

@ -28,8 +28,9 @@
#ifndef _AmMediaProcessor_h_
#define _AmMediaProcessor_h_
#include "AmSession.h"
#include "AmEventQueue.h"
#include "amci/amci.h" // AUDIO_BUFFER_SIZE
class AmSession;
#include <set>
using std::set;

@ -37,7 +37,7 @@
// the internal delay of the mixer (between put and get)
#define MIXER_DELAY_MS 20
#define MIXER_DELAY MIXER_DELAY_MS*8 // 8000/1000
#define MIXER_DELAY MIXER_DELAY_MS*SYSTEM_SAMPLERATE/1000
AmMultiPartyMixer::AmMultiPartyMixer()
: channels(),

@ -42,7 +42,7 @@
#define PI 3.14
#define MAX_DELAY 8000 /* 1 second */
#define MAX_DELAY SYSTEM_SAMPLERATE*1 /* 1 second */
AmPlayoutBuffer::AmPlayoutBuffer(AmPLCBuffer *plcbuffer)
: r_ts(0),w_ts(0),

@ -42,18 +42,18 @@ using std::multiset;
#define EXP_THRESHOLD 20
#define SHR_THRESHOLD 180
#define WSOLA_START_OFF 80
#define WSOLA_START_OFF 10 * SYSTEM_SAMPLERATE / 1000
#define WSOLA_SCALED_WIN 50
// the maximum packet size that will be processed
// 640 is 80ms @ 8khz
#define MAX_PACKET_SAMPLES 640
// search segments of size TEMPLATE_SEG samples
#define TEMPLATE_SEG 80
// the maximum packet size that will be processed (80ms)
#define MAX_PACKET_SAMPLES 80 * SYSTEM_SAMPLERATE / 1000
// search segments of size TEMPLATE_SEG samples (10 ms)
#define TEMPLATE_SEG 10 * SYSTEM_SAMPLERATE / 1000
// Maximum value: AUDIO_BUFFER_SIZE / 2
// Note: plc result get stored in our back buffer
#define PLC_MAX_SAMPLES (160*4)
// maximum of 80ms PLC
#define PLC_MAX_SAMPLES (4*20*SYSTEM_SAMPLERATE / 1000)
class AmPLCBuffer;

@ -92,7 +92,7 @@ amci_codec_t _codec_tevent = {
amci_payload_t _payload_tevent = {
-1,
"telephone-event",
8000,
8000, // telephone-event has always SR 8000
-1,
CODEC_TELEPHONE_EVENT,
-1

@ -34,9 +34,9 @@ int AmRingTone::read(unsigned int user_ts, unsigned int size)
for(unsigned int i=0; i<PCM16_B2S(size); i++, s++, t++){
if(t < on_period<<3){
float fs = sin((float(t*freq)/8000.0)*2.0*PI)*15000.0;
float fs = sin((float(t*freq)/(float)SYSTEM_SAMPLERATE)*2.0*PI)*15000.0;
if(freq2 != 0)
fs += sin((float(t*freq2)/8000.0)*2.0*PI)*15000.0;
fs += sin((float(t*freq2)/(float)SYSTEM_SAMPLERATE)*2.0*PI)*15000.0;
*s = (short)(fs);
}
else

@ -28,6 +28,7 @@
#ifndef _LowcFE_h_
#define _LowcFE_h_
#include "AmAudio.h"
typedef float Float;
@ -37,13 +38,13 @@ typedef float Float;
#define POVERLAPMAX (PITCH_MAX >> 2) /* maximum pitch OLA window */
#define HISTORYLEN (PITCH_MAX * 3 + POVERLAPMAX) /* history buff length*/
#define NDEC 2 /* 2:1 decimation */
#define CORRLEN 160 /* 20 msec correlation length */
#define CORRLEN 20 * SYSTEM_SAMPLERATE / 1000 /* 20 msec correlation length */
#define CORRBUFLEN (CORRLEN + PITCH_MAX) /* correlation buffer length */
#define CORRMINPOWER ((Float)250.) /* minimum power */
#define EOVERLAPINCR 32 /* end OLA increment per frame,4 ms */
#define FRAMESZ 80 /* 10 msec at 8 KHz */
#define FRAMESZ (10 * SYSTEM_SAMPLERATE / 1000) /* 10 msec */
#define ATTENFAC ((Float).2) /* attenu. factor per 10 ms frame */
#define ATTENINCR (ATTENFAC/FRAMESZ) /* attenuation per sample */
#define ATTENINCR (ATTENFAC/(Float)(FRAMESZ)) /* attenuation per sample */
/** \brief LowcFE erased frame generator for fec (plc) */
class LowcFE {

Loading…
Cancel
Save