# Path: chirp/common/mp3_header.py
# STEREO = 0
# JOINT_STEREO = 1
# DUAL_MONO = 2
# MONO = 3
# _CHANNELS_TO_STR = {
#     STEREO: 'stereo',
#     JOINT_STEREO: 'joint_stereo',
#     DUAL_MONO: 'dual_mono',
#     MONO: 'mono',
#     None: None,
# }
# _PROTECTED_TABLE = (True, False)
# _BIT_RATE_KBPS_TABLE = (0, 32, 40, 48, 56, 64, 80, 96,
#                         112, 128, 160, 192, 224, 256, 320)
# _SAMPLING_RATE_HZ_TABLE = (44100, 48000, 32000)
# _PADDING_TABLE = (False, True)
# _SAMPLES_PER_FRAME = 1152
# def _match_eq(x, y):
#     def __init__(self, sampling_rate_hz=None, bit_rate_kbps=None,
#                  channels=None, protected=None, padding=None):
#     def is_complete(self):
#     def match(self, hdr):
#     def __str__(self):
# def parse(data, offset=0):
# def find(data, expected_hdr=None):
# def from_mutagen(mutagen_mp3):
# class MP3Header(object):
# 
# Path: chirp/library/audio_file.py
# class AudioFile(object):
#     def __eq__(self, other):
#         def _mutagen_id3_set(obj):
#     def has_ufid(self):
#     def ufid(self):
#     def ufid_tag(self):
#     def tpe1(self):
#     def talb(self):
#     def tit2(self):
#     def canonical_directory(self, prefix=""):
#     def canonical_filename(self):
#     def canonical_path(self, prefix=""):
# def _get_mp3(path):
# def _tag_to_int(au_file, tag_key):
# def scan_fast(path, _read_id3_hook=None):
# def scan(path, _read_id3_hook=None):


from chirp.common import mp3_header
from chirp.library import audio_file
CREATE UNIQUE INDEX audio_files_index_fingerprint
ON audio_files ( fingerprint )
"""


create_id3_tags_table = """
CREATE TABLE id3_tags (
    fingerprint TEXT,  /* Fingerprint of the file this tag is part of */
    timestamp INTEGER, /* Timestamp of this ID3 tag */
    frame_id TEXT,     /* The value of this_mutagen_id3_tag.FrameID */
    value TEXT,        /* For text tags,  unicode(this_mutagen_id3_tag) */
    mutagen_repr TEXT  /* Very Python- and Mutagen-specific */
)
"""


create_id3_tags_index = """
CREATE INDEX id3_tags_index_fingerprint
ON id3_tags ( fingerprint, timestamp DESC )
"""


def audio_file_to_tuple(au_file):
    """Turn an AudioFile object into an insertable tuple."""
    return (au_file.volume,
            au_file.import_timestamp,
            au_file.fingerprint,
            au_file.album_id,
            au_file.mp3_header.sampling_rate_hz,
            au_file.mp3_header.bit_rate_kbps,

# Path: chirp/common/mp3_header.py
# STEREO = 0
# JOINT_STEREO = 1
# DUAL_MONO = 2
# MONO = 3
# _CHANNELS_TO_STR = {
#     STEREO: 'stereo',
#     JOINT_STEREO: 'joint_stereo',
#     DUAL_MONO: 'dual_mono',
#     MONO: 'mono',
#     None: None,
# }
# _PROTECTED_TABLE = (True, False)
# _BIT_RATE_KBPS_TABLE = (0, 32, 40, 48, 56, 64, 80, 96,
#                         112, 128, 160, 192, 224, 256, 320)
# _SAMPLING_RATE_HZ_TABLE = (44100, 48000, 32000)
# _PADDING_TABLE = (False, True)
# _SAMPLES_PER_FRAME = 1152
# def _match_eq(x, y):
#     def __init__(self, sampling_rate_hz=None, bit_rate_kbps=None,
#                  channels=None, protected=None, padding=None):
#     def is_complete(self):
#     def match(self, hdr):
#     def __str__(self):
# def parse(data, offset=0):
# def find(data, expected_hdr=None):
# def from_mutagen(mutagen_mp3):
# class MP3Header(object):
# 
# Path: chirp/library/audio_file.py
# class AudioFile(object):
#     def __eq__(self, other):
#         def _mutagen_id3_set(obj):
#     def has_ufid(self):
#     def ufid(self):
#     def ufid_tag(self):
#     def tpe1(self):
#     def talb(self):
#     def tit2(self):
#     def canonical_directory(self, prefix=""):
#     def canonical_filename(self):
#     def canonical_path(self, prefix=""):
# def _get_mp3(path):
# def _tag_to_int(au_file, tag_key):
# def scan_fast(path, _read_id3_hook=None):
# def scan(path, _read_id3_hook=None):


# Path: chirp/library/schema.py
from chirp.common import mp3_header
from chirp.library import audio_file

CREATE UNIQUE INDEX audio_files_index_fingerprint
ON audio_files ( fingerprint )
"""


create_id3_tags_table = """
CREATE TABLE id3_tags (
    fingerprint TEXT,  /* Fingerprint of the file this tag is part of */
    timestamp INTEGER, /* Timestamp of this ID3 tag */
    frame_id TEXT,     /* The value of this_mutagen_id3_tag.FrameID */
    value TEXT,        /* For text tags,  unicode(this_mutagen_id3_tag) */
    mutagen_repr TEXT  /* Very Python- and Mutagen-specific */
)
"""


create_id3_tags_index = """
CREATE INDEX id3_tags_index_fingerprint
ON id3_tags ( fingerprint, timestamp DESC )
"""


def audio_file_to_tuple(au_file):
    """Turn an AudioFile object into an insertable tuple."""
    return (au_file.volume,
            au_file.import_timestamp,
            au_file.fingerprint,
            au_file.album_id,
            au_file.mp3_header.sampling_rate_hz,
            au_file.mp3_header.bit_rate_kbps,

            au_file.mp3_header.channels,