{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# `wavinfo` Demonstration\n",
    "\n",
    "The entry point for wavinfo is the WavInfoReader class."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from wavinfo import WavInfoReader\n",
    "\n",
    "path = '../tests/test_files/sounddevices/A101_1.WAV'\n",
    "\n",
    "info = WavInfoReader(path)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Basic WAV Data\n",
    "\n",
    "The length of the file in frames (interleaved samples) and bytes is available, as is the contents of the format chunk."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(240239, 1441434)"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(info.data.frame_count, info.data.byte_count)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(48000, 2, 6, 24)"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "(info.fmt.sample_rate, info.fmt.channel_count, info.fmt.block_align, info.fmt.bits_per_sample)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Broadcast WAV Extension"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "sSPEED=023.976-ND\r\n",
      "sTAKE=1\r\n",
      "sUBITS=$12311801\r\n",
      "sSWVER=2.67\r\n",
      "sPROJECT=BMH\r\n",
      "sSCENE=A101\r\n",
      "sFILENAME=A101_1.WAV\r\n",
      "sTAPE=18Y12M31\r\n",
      "sTRK1=MKH516 A\r\n",
      "sTRK2=Boom\r\n",
      "sNOTE=\r\n",
      "\n",
      "----------\n",
      "Originator: Sound Dev: 702T S#GR1112089007\n",
      "Originator Ref: USSDVGR1112089007124001008206301\n",
      "Originator Date: 2018-12-31\n",
      "Originator Time: 12:40:00\n",
      "Time Reference: 2190940753\n",
      "A=PCM,F=48000,W=24,M=stereo,R=48000,T=2 Ch\r\n",
      "\n"
     ]
    }
   ],
   "source": [
    "print(info.bext.description)\n",
    "print(\"----------\")\n",
    "print(\"Originator:\", info.bext.originator)\n",
    "print(\"Originator Ref:\", info.bext.originator_ref)\n",
    "print(\"Originator Date:\", info.bext.originator_date)\n",
    "print(\"Originator Time:\", info.bext.originator_time)\n",
    "print(\"Time Reference:\", info.bext.time_reference)\n",
    "print(info.bext.coding_history)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## iXML Production Recorder Metadata"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "iXML Project: BMH\n",
      "iXML Scene: A101\n",
      "iXML Take: 1\n",
      "iXML Tape: 18Y12M31\n",
      "iXML File Family Name: None\n",
      "iXML File Family UID: USSDVGR1112089007124001008206300\n"
     ]
    }
   ],
   "source": [
    "print(\"iXML Project:\", info.ixml.project)\n",
    "print(\"iXML Scene:\", info.ixml.scene)\n",
    "print(\"iXML Take:\", info.ixml.take)\n",
    "print(\"iXML Tape:\", info.ixml.tape)\n",
    "print(\"iXML File Family Name:\", info.ixml.family_name)\n",
    "print(\"iXML File Family UID:\", info.ixml.family_uid)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
