tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

input_audio_file.h (2406B)


      1 /*
      2 *  Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
      3 *
      4 *  Use of this source code is governed by a BSD-style license
      5 *  that can be found in the LICENSE file in the root of the source
      6 *  tree. An additional intellectual property rights grant can be found
      7 *  in the file PATENTS.  All contributing project authors may
      8 *  be found in the AUTHORS file in the root of the source tree.
      9 */
     10 
     11 #ifndef MODULES_AUDIO_CODING_NETEQ_TOOLS_INPUT_AUDIO_FILE_H_
     12 #define MODULES_AUDIO_CODING_NETEQ_TOOLS_INPUT_AUDIO_FILE_H_
     13 
     14 #include <stdint.h>
     15 #include <stdio.h>
     16 
     17 
     18 #include "absl/strings/string_view.h"
     19 
     20 namespace webrtc {
     21 namespace test {
     22 
     23 // Class for handling a looping input audio file.
     24 class InputAudioFile {
     25 public:
     26  explicit InputAudioFile(absl::string_view file_name, bool loop_at_end = true);
     27 
     28  virtual ~InputAudioFile();
     29 
     30  InputAudioFile(const InputAudioFile&) = delete;
     31  InputAudioFile& operator=(const InputAudioFile&) = delete;
     32 
     33  // Reads `samples` elements from source file to `destination`. Returns true
     34  // if the read was successful, otherwise false. If the file end is reached,
     35  // the file is rewound and reading continues from the beginning.
     36  // The output `destination` must have the capacity to hold `samples` elements.
     37  virtual bool Read(size_t samples, int16_t* destination);
     38 
     39  // Fast-forwards (`samples` > 0) or -backwards (`samples` < 0) the file by the
     40  // indicated number of samples. Just like Read(), Seek() starts over at the
     41  // beginning of the file if the end is reached. However, seeking backwards
     42  // past the beginning of the file is not possible.
     43  virtual bool Seek(int samples);
     44 
     45  // Creates a multi-channel signal from a mono signal. Each sample is repeated
     46  // `channels` times to create an interleaved multi-channel signal where all
     47  // channels are identical. The output `destination` must have the capacity to
     48  // hold samples * channels elements. Note that `source` and `destination` can
     49  // be the same array (i.e., point to the same address).
     50  static void DuplicateInterleaved(const int16_t* source,
     51                                   size_t samples,
     52                                   size_t channels,
     53                                   int16_t* destination);
     54 
     55 private:
     56  FILE* fp_;
     57  const bool loop_at_end_;
     58 };
     59 
     60 }  // namespace test
     61 }  // namespace webrtc
     62 #endif  // MODULES_AUDIO_CODING_NETEQ_TOOLS_INPUT_AUDIO_FILE_H_