{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "db7bef42",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-09-19T16:39:44.101105Z",
     "start_time": "2023-09-19T16:39:43.996160Z"
    }
   },
   "outputs": [],
   "source": [
    "import os\n",
    "import numpy as np\n",
    "import pickle"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "4299caa7",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-09-19T16:39:44.106620Z",
     "start_time": "2023-09-19T16:39:44.104456Z"
    }
   },
   "outputs": [],
   "source": [
    "dummy_path = \"/app/suno/data/audio_v0/audio_48khz_2ch_dummy.bin\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "28b38532",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-09-19T16:39:44.160729Z",
     "start_time": "2023-09-19T16:39:44.109534Z"
    }
   },
   "outputs": [],
   "source": [
    "dummy_data = np.memmap(dummy_path, dtype=np.int16, mode=\"r\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "0bf1247b",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-09-19T16:42:06.417706Z",
     "start_time": "2023-09-19T16:42:06.416000Z"
    }
   },
   "outputs": [],
   "source": [
    "val_path = \"/app/suno/data/audio_v0/audio_48khz_2ch_tr.bin\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "6cc90006",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-09-19T16:42:07.067868Z",
     "start_time": "2023-09-19T16:42:07.064868Z"
    }
   },
   "outputs": [],
   "source": [
    "val_data = np.memmap(val_path, dtype=np.int16, mode=\"r\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "81374aa3",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-09-19T16:42:07.271139Z",
     "start_time": "2023-09-19T16:42:07.269183Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(1971673073552,)"
      ]
     },
     "execution_count": 26,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "val_data.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "d037b73a",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-09-19T16:42:07.463766Z",
     "start_time": "2023-09-19T16:42:07.458227Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "2687.8468818660017"
      ]
     },
     "execution_count": 27,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "val_data[:100000].std()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "b8078174",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-09-19T16:42:07.628827Z",
     "start_time": "2023-09-19T16:42:07.626738Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(2, 500)"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "val_data[:1000].reshape(-1, 2).T.shape"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "43443467",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-09-19T16:42:08.299427Z",
     "start_time": "2023-09-19T16:42:08.297914Z"
    }
   },
   "outputs": [],
   "source": [
    "test_array = np.array([[0, 0, 0, 1, 2, 3]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "c471e9a3",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-09-19T16:42:09.664905Z",
     "start_time": "2023-09-19T16:42:09.662830Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0, 0, 2],\n",
       "       [0, 1, 3]])"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test_array.reshape(-1, 2).T"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "id": "cb4cf672",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-09-19T16:42:09.849783Z",
     "start_time": "2023-09-19T16:42:09.847760Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0, 0, 0],\n",
       "       [1, 2, 3]])"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test_array.reshape([2, -1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "id": "a534ec10",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-09-19T16:42:10.015749Z",
     "start_time": "2023-09-19T16:42:10.014235Z"
    }
   },
   "outputs": [],
   "source": [
    "test_array2 = np.array([[0, 1, 0, 2, 0, 3]])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "221bcd46",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-09-19T16:42:10.161138Z",
     "start_time": "2023-09-19T16:42:10.159106Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0, 0, 0],\n",
       "       [1, 2, 3]])"
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test_array2.reshape(-1, 2).T"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "id": "314522fc",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-09-19T16:42:10.600868Z",
     "start_time": "2023-09-19T16:42:10.598822Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0, 0, 0],\n",
       "       [1, 2, 3]])"
      ]
     },
     "execution_count": 34,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "test_array.reshape([2, -1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "id": "e597c6be",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-09-19T16:42:11.092471Z",
     "start_time": "2023-09-19T16:42:11.090352Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "memmap([[-38, -39, -40, ...,   0,   0,   0],\n",
       "        [  0,   0,   0, ...,  26,  21,  17]], dtype=int16)"
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dummy_data.reshape(-1, 2).T"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "cade1832",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-09-19T16:42:11.649507Z",
     "start_time": "2023-09-19T16:42:11.589841Z"
    }
   },
   "outputs": [],
   "source": [
    "val_left, val_right = val_data.reshape(-1, 2).T"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "id": "f9ec0fc6",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-09-19T16:42:18.874958Z",
     "start_time": "2023-09-19T16:42:12.477437Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "864.1717335706019"
      ]
     },
     "execution_count": 37,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "n_steps = 48000 * 3600\n",
    "np.mean(np.abs(val_left[-n_steps:] - val_right[-n_steps:]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "id": "91c9e1dd",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-09-19T16:42:24.891327Z",
     "start_time": "2023-09-19T16:42:18.876426Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0.0"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "n_steps = 48000 * 3600\n",
    "np.mean(np.abs(val_left[:n_steps] - val_right[:n_steps]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "dc7f68f0",
   "metadata": {
    "ExecuteTime": {
     "start_time": "2023-09-19T16:46:25.548Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n",
      "0.0\n"
     ]
    }
   ],
   "source": [
    "# n_steps = 48000 * 3600\n",
    "# i = 10\n",
    "# diffs = []\n",
    "# for i in range(100):\n",
    "#     v = np.mean(np.abs(val_left[n_steps * i: (n_steps * (i + 1))] - val_right[n_steps * i: (n_steps * (i + 1))]))\n",
    "#     print(v)\n",
    "#     diffs.append(v)\n",
    "# print(diffs)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "id": "d17d75d2",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-09-19T16:43:50.820761Z",
     "start_time": "2023-09-19T16:43:50.818450Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "172800000"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "n_steps"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "f778a000",
   "metadata": {
    "ExecuteTime": {
     "end_time": "2023-09-19T16:43:59.077046Z",
     "start_time": "2023-09-19T16:43:59.075060Z"
    }
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5705.0725507870375"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(val_left) / n_steps"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "34a430e6",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "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.10.12"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
