# Path: note_seq/audio_io.py
# class AudioIOError(BaseException):  # pylint:disable=g-bad-exception-name
# class AudioIOReadError(AudioIOError):
# class AudioIODataTypeError(AudioIOError):
# def int16_samples_to_float32(y):
# def float_samples_to_int16(y):
# def wav_data_to_samples_pydub(wav_data: bytes,
#                               sample_rate: int,
#                               remove_dc_bias: bool = False,
#                               num_channels: int = None,
#                               normalize_db: float = None):
# def wav_data_to_samples(wav_data, sample_rate):
# def wav_data_to_samples_librosa(audio_file, sample_rate):
# def samples_to_wav_data(samples, sample_rate):
# def crop_samples(samples, sample_rate, crop_beginning_seconds,
#                  total_length_seconds):
# def repeat_samples_to_duration(samples, sample_rate, duration):
# def crop_wav_data(wav_data, sample_rate, crop_beginning_seconds,
#                   total_length_seconds):
# def jitter_wav_data(wav_data, sample_rate, jitter_seconds):
# def load_audio(audio_filename, sample_rate):
# def make_stereo(left, right):
# def normalize_wav_data(wav_data, sample_rate, norm=np.inf):
# 
# Path: note_seq/testing_lib.py
# BEAT = music_pb2.NoteSequence.TextAnnotation.BEAT
# CHORD_SYMBOL = music_pb2.NoteSequence.TextAnnotation.CHORD_SYMBOL
# def add_track_to_sequence(note_sequence,
#                           instrument,
#                           notes,
#                           is_drum=False,
#                           program=0):
# def add_chords_to_sequence(note_sequence, chords):
# def add_key_signatures_to_sequence(note_sequence, keys):
# def add_beats_to_sequence(note_sequence, beats, beats_per_bar=None):
# def add_control_changes_to_sequence(note_sequence, instrument, control_changes):
# def add_pitch_bends_to_sequence(
#     note_sequence, instrument, program, pitch_bends):
# def add_quantized_steps_to_sequence(sequence, quantized_steps):
# def add_quantized_chord_steps_to_sequence(sequence, quantized_steps):
# def add_quantized_control_steps_to_sequence(sequence, quantized_steps):
#   def __init__(self, num_classes, num_steps=None):
#   def num_classes(self):
#   def default_event(self):
#   def encode_event(self, event):
#   def decode_event(self, index):
#   def event_to_num_steps(self, event):
# def parse_test_proto(proto_type, proto_string):
# def get_testdata_dir():
#   def setUp(self):
#   def _AssertProtoEquals(self, a, b, msg=None):  # pylint:disable=invalid-name
#   def assertProtoEquals(self, expected_message_maybe_ascii, message, msg=None):
# class TrivialOneHotEncoding(encoder_decoder.OneHotEncoding):
# class ProtoTestCase(absltest.TestCase):


import io
import os
import wave
import numpy as np
import scipy
from absl.testing import absltest
from note_seq import audio_io
from note_seq import testing_lib
# Copyright 2022 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Tests for audio_io.py."""




class AudioIoTest(absltest.TestCase):

  def setUp(self):
    super().setUp()
    self.wav_filename = os.path.join(
        testing_lib.get_testdata_dir(), 'example.wav')
    self.wav_filename_mono = os.path.join(

# Path: note_seq/audio_io.py
# class AudioIOError(BaseException):  # pylint:disable=g-bad-exception-name
# class AudioIOReadError(AudioIOError):
# class AudioIODataTypeError(AudioIOError):
# def int16_samples_to_float32(y):
# def float_samples_to_int16(y):
# def wav_data_to_samples_pydub(wav_data: bytes,
#                               sample_rate: int,
#                               remove_dc_bias: bool = False,
#                               num_channels: int = None,
#                               normalize_db: float = None):
# def wav_data_to_samples(wav_data, sample_rate):
# def wav_data_to_samples_librosa(audio_file, sample_rate):
# def samples_to_wav_data(samples, sample_rate):
# def crop_samples(samples, sample_rate, crop_beginning_seconds,
#                  total_length_seconds):
# def repeat_samples_to_duration(samples, sample_rate, duration):
# def crop_wav_data(wav_data, sample_rate, crop_beginning_seconds,
#                   total_length_seconds):
# def jitter_wav_data(wav_data, sample_rate, jitter_seconds):
# def load_audio(audio_filename, sample_rate):
# def make_stereo(left, right):
# def normalize_wav_data(wav_data, sample_rate, norm=np.inf):
# 
# Path: note_seq/testing_lib.py
# BEAT = music_pb2.NoteSequence.TextAnnotation.BEAT
# CHORD_SYMBOL = music_pb2.NoteSequence.TextAnnotation.CHORD_SYMBOL
# def add_track_to_sequence(note_sequence,
#                           instrument,
#                           notes,
#                           is_drum=False,
#                           program=0):
# def add_chords_to_sequence(note_sequence, chords):
# def add_key_signatures_to_sequence(note_sequence, keys):
# def add_beats_to_sequence(note_sequence, beats, beats_per_bar=None):
# def add_control_changes_to_sequence(note_sequence, instrument, control_changes):
# def add_pitch_bends_to_sequence(
#     note_sequence, instrument, program, pitch_bends):
# def add_quantized_steps_to_sequence(sequence, quantized_steps):
# def add_quantized_chord_steps_to_sequence(sequence, quantized_steps):
# def add_quantized_control_steps_to_sequence(sequence, quantized_steps):
#   def __init__(self, num_classes, num_steps=None):
#   def num_classes(self):
#   def default_event(self):
#   def encode_event(self, event):
#   def decode_event(self, index):
#   def event_to_num_steps(self, event):
# def parse_test_proto(proto_type, proto_string):
# def get_testdata_dir():
#   def setUp(self):
#   def _AssertProtoEquals(self, a, b, msg=None):  # pylint:disable=invalid-name
#   def assertProtoEquals(self, expected_message_maybe_ascii, message, msg=None):
# class TrivialOneHotEncoding(encoder_decoder.OneHotEncoding):
# class ProtoTestCase(absltest.TestCase):


# Path: note_seq/audio_io_test.py
import io
import os
import wave
import numpy as np
import scipy
from absl.testing import absltest
from note_seq import audio_io
from note_seq import testing_lib

# Copyright 2022 The Magenta Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

"""Tests for audio_io.py."""




class AudioIoTest(absltest.TestCase):

  def setUp(self):
    super().setUp()
    self.wav_filename = os.path.join(
        testing_lib.get_testdata_dir(), 'example.wav')
    self.wav_filename_mono = os.path.join(

        testing_lib.get_testdata_dir(), 'example_mono.wav')