blob: 3c47618be8adff62a831c06ea57b15a133a1ef4b [file] [log] [blame]
// Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// Implementation of TtsDataReceiver that resamples the audio to a
// different sample rate and then passes the resampled audio through
// to another callback.
#include <stdint.h>
#include <cstring>
#ifndef SPEECH_CLIENT_SYNTHESIS_SERVICE_RESAMPLER_H_
#define SPEECH_CLIENT_SYNTHESIS_SERVICE_RESAMPLER_H_
#include "tts_receiver.h"
namespace speech_synthesis {
class Resampler : public TtsDataReceiver {
public:
// Resamples the audio passed to this object's Receive method and passes
// the resampled audio through to the destination.
Resampler(TtsDataReceiver *destination,
int source_rate,
int dest_rate,
int buffer_size);
virtual ~Resampler();
virtual tts_callback_status Receive(int rate,
int num_channels,
const int16_t* data,
int num_samples,
tts_synth_status status);
int source_rate() { return source_rate_; }
int dest_rate() { return dest_rate_; }
private:
TtsDataReceiver* destination_;
int source_rate_;
int dest_rate_;
double factor_;
int buffer_size_;
void* resample_handle_;
float* in_floats_;
float* out_floats_;
int16_t* out_int16s_;
};
} // namespace speech_synthesis
#endif // SPEECH_CLIENT_SYNTHESIS_SERVICE_RESAMPLER_H_