Author: sayer
Date: 2008-07-16 15:51:22 +0200 (Wed, 16 Jul 2008)
New Revision: 1051
Modified:
trunk/core/AmAdvancedAudio.cpp
trunk/core/AmAudio.cpp
trunk/core/AmAudio.h
trunk/core/AmAudioMixIn.h
trunk/core/AmDtmfDetector.cpp
trunk/core/AmJitterBuffer.h
trunk/core/AmMediaProcessor.cpp
trunk/core/AmMediaProcessor.h
trunk/core/AmMultiPartyMixer.cpp
trunk/core/AmPlayoutBuffer.cpp
trunk/core/AmPlayoutBuffer.h
trunk/core/AmPlugIn.cpp
trunk/core/AmRingTone.cpp
trunk/core/LowcFE.h
Log:
use define SYSTEM_SAMPLERATE everywhere
Modified: trunk/core/AmAdvancedAudio.cpp
===================================================================
--- trunk/core/AmAdvancedAudio.cpp 2008-07-16 13:01:40 UTC (rev 1050)
+++ trunk/core/AmAdvancedAudio.cpp 2008-07-16 13:51:22 UTC (rev 1051)
@@ -223,7 +223,7 @@
}
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;
}
Modified: trunk/core/AmAudio.cpp
===================================================================
--- trunk/core/AmAudio.cpp 2008-07-16 13:01:40 UTC (rev 1050)
+++ trunk/core/AmAudio.cpp 2008-07-16 13:51:22 UTC (rev 1051)
@@ -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 @@
: AmAudioFormat(), codec_id(codec_id)
{
codec = getCodec();
- rate = 8000;
+ rate = SYSTEM_SAMPLERATE;
channels = 1;
}
@@ -275,6 +273,7 @@
}
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 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();
Modified: trunk/core/AmAudio.h
===================================================================
--- trunk/core/AmAudio.h 2008-07-16 13:01:40 UTC (rev 1050)
+++ trunk/core/AmAudio.h 2008-07-16 13:51:22 UTC (rev 1051)
@@ -47,6 +47,8 @@
#define PCM16_B2S(b) ((b) >> 1)
#define PCM16_S2B(s) ((s) << 1)
+#define SYSTEM_SAMPLERATE 8000 // fixme: sr per session
+
class SdpPayload;
class CodecContainer;
Modified: trunk/core/AmAudioMixIn.h
===================================================================
--- trunk/core/AmAudioMixIn.h 2008-07-16 13:01:40 UTC (rev 1050)
+++ trunk/core/AmAudioMixIn.h 2008-07-16 13:51:22 UTC (rev 1051)
@@ -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
Modified: trunk/core/AmDtmfDetector.cpp
===================================================================
--- trunk/core/AmDtmfDetector.cpp 2008-07-16 13:01:40 UTC (rev 1050)
+++ trunk/core/AmDtmfDetector.cpp 2008-07-16 13:51:22 UTC (rev 1051)
@@ -462,7 +462,7 @@
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++) {
Modified: trunk/core/AmJitterBuffer.h
===================================================================
--- trunk/core/AmJitterBuffer.h 2008-07-16 13:01:40 UTC (rev 1050)
+++ trunk/core/AmJitterBuffer.h 2008-07-16 13:51:22 UTC (rev 1051)
@@ -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 {
Modified: trunk/core/AmMediaProcessor.cpp
===================================================================
--- trunk/core/AmMediaProcessor.cpp 2008-07-16 13:01:40 UTC (rev 1050)
+++ trunk/core/AmMediaProcessor.cpp 2008-07-16 13:51:22 UTC (rev 1051)
@@ -26,6 +26,7 @@
*/
#include "AmMediaProcessor.h"
+#include "AmSession.h"
#include "AmRtpStream.h"
#include <assert.h>
@@ -212,7 +213,7 @@
events.processEvents();
processDtmfEvents();
- ts += 80; // 10 ms
+ ts += 10 * SYSTEM_SAMPLERATE / 1000; // 10 ms
timeradd(&tick,&next_tick,&next_tick);
}
}
Modified: trunk/core/AmMediaProcessor.h
===================================================================
--- trunk/core/AmMediaProcessor.h 2008-07-16 13:01:40 UTC (rev 1050)
+++ trunk/core/AmMediaProcessor.h 2008-07-16 13:51:22 UTC (rev 1051)
@@ -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;
Modified: trunk/core/AmMultiPartyMixer.cpp
===================================================================
--- trunk/core/AmMultiPartyMixer.cpp 2008-07-16 13:01:40 UTC (rev 1050)
+++ trunk/core/AmMultiPartyMixer.cpp 2008-07-16 13:51:22 UTC (rev 1051)
@@ -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(),
Modified: trunk/core/AmPlayoutBuffer.cpp
===================================================================
--- trunk/core/AmPlayoutBuffer.cpp 2008-07-16 13:01:40 UTC (rev 1050)
+++ trunk/core/AmPlayoutBuffer.cpp 2008-07-16 13:51:22 UTC (rev 1051)
@@ -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),
Modified: trunk/core/AmPlayoutBuffer.h
===================================================================
--- trunk/core/AmPlayoutBuffer.h 2008-07-16 13:01:40 UTC (rev 1050)
+++ trunk/core/AmPlayoutBuffer.h 2008-07-16 13:51:22 UTC (rev 1051)
@@ -42,18 +42,18 @@
#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;
Modified: trunk/core/AmPlugIn.cpp
===================================================================
--- trunk/core/AmPlugIn.cpp 2008-07-16 13:01:40 UTC (rev 1050)
+++ trunk/core/AmPlugIn.cpp 2008-07-16 13:51:22 UTC (rev 1051)
@@ -92,7 +92,7 @@
amci_payload_t _payload_tevent = {
-1,
"telephone-event",
- 8000,
+ 8000, // telephone-event has always SR 8000
-1,
CODEC_TELEPHONE_EVENT,
-1
Modified: trunk/core/AmRingTone.cpp
===================================================================
--- trunk/core/AmRingTone.cpp 2008-07-16 13:01:40 UTC (rev 1050)
+++ trunk/core/AmRingTone.cpp 2008-07-16 13:51:22 UTC (rev 1051)
@@ -34,9 +34,9 @@
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
Modified: trunk/core/LowcFE.h
===================================================================
--- trunk/core/LowcFE.h 2008-07-16 13:01:40 UTC (rev 1050)
+++ trunk/core/LowcFE.h 2008-07-16 13:51:22 UTC (rev 1051)
@@ -28,6 +28,7 @@
#ifndef _LowcFE_h_
#define _LowcFE_h_
+#include "AmAudio.h"
typedef float Float;
@@ -37,13 +38,13 @@
#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 {
_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev