<commit_before>{
 "metadata": {
  "name": "",
  "signature": "sha256:2042c15135d4f11367fd0464d7f99906d700fa4c691ac753ad5570e013f773d3"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import os, sys\n",
      "import numpy as np\n",
      "parent_folder = os.path.split(os.path.abspath('.'))[0]\n",
      "sys.path.append(parent_folder)\n",
      "from TimeFreqAuditoryScene import *\n",
      "from IPython.display import Audio, display, clear_output\n",
      "from IPython.html import widgets\n",
      "from IPython.html.widgets import interactive\n",
      "%matplotlib inline"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "## Generating Shepard tones from coupled streams\n",
      "fs = 44100\n",
      "\n",
      "interval=2.\n",
      "n_tones=20\n",
      "mu_log=np.log(200)\n",
      "sigma_log=2.\n",
      "genv = GaussianSpectralEnvelope(mu_log=mu_log, sigma_log=sigma_log)\n",
      "\n",
      "\n",
      "scene = Scene()\n",
      "band=[200.,300.]\n",
      "freqs = list( band[0]* (band[1]/band[0])**np.random.rand(n_tones,)  )\n",
      "for i in range(-5,5):\n",
      "    ts = ToneSequence(freqs=freqs,env=genv, intertone_delay=0,tone_duration=0.1)\n",
      "    ts.shift_tones(shift=interval**i)\n",
      "    scene.List.append(ts)\n",
      "scene.List\n",
      "scene.draw_spectrogram()\n",
      "x = scene.generate(fs=fs)\n",
      "print x.shape\n",
      "\n",
      "display(Audio(x, rate=fs, autoplay=True))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "## Generating independent Uniform banded streams of tones \n",
      "\n",
      "fs = 44100\n",
      "mu_log=np.log(200)\n",
      "sigma_log=2.\n",
      "genv = GaussianSpectralEnvelope(mu_log=mu_log, sigma_log=sigma_log)\n",
      "interval=2.\n",
      "n_tones = 20\n",
      "\n",
      "\n",
      "fmin = 100.\n",
      "fmax = fmin*np.sqrt(interval)\n",
      "scene = Scene()\n",
      "for i in range(-5,5):\n",
      "    ts = UniformToneSequence(n_tones=n_tones,tone_duration=0.1, intertone_delay=0.,band=[fmin*interval**i, fmax*interval**i],env=genv)\n",
      "    scene.List.append(ts)\n",
      "scene.List\n",
      "scene.draw_spectrogram()\n",
      "x = scene.generate(fs=fs)\n",
      "print x.shape\n",
      "\n",
      "display(Audio(x, rate=fs, autoplay=True))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "[fmin,fmax]"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}<commit_msg>correlated(shepard) and uncorrelated streams bias<commit_after>{
 "metadata": {
  "name": "",
  "signature": "sha256:f3f494e90ae12d3b8e3176c59d8e661515a4132079ed12b6a227d88d1ae7b5eb"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import os, sys\n",
      "import numpy as np\n",
      "parent_folder = os.path.split(os.path.abspath('.'))[0]\n",
      "sys.path.append(parent_folder)\n",
      "from TimeFreqAuditoryScene import *\n",
      "from IPython.display import Audio, display, clear_output\n",
      "from IPython.html import widgets\n",
      "from IPython.html.widgets import interactive\n",
      "%matplotlib inline"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "fs = 44100\n",
      "interval=2.\n",
      "n_tones=3\n",
      "mu_log=np.log(200)\n",
      "sigma_log=2.\n",
      "genv = GaussianSpectralEnvelope(mu_log=mu_log, sigma_log=sigma_log)\n",
      "tone_duration=0.2\n",
      "\n",
      "fmin = 100.\n",
      "fmax = fmin*np.sqrt(interval)\n",
      "band_base = [fmin,fmax]"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "## Generating Shepard tones from coupled streams\n",
      "\n",
      "\n",
      "scene = Scene(List=[])\n",
      "band=band_base\n",
      "\n",
      "context = Node(List=[])\n",
      "freqs = list( band[0]* (band[1]/band[0])**np.random.rand(n_tones,)  )\n",
      "for i in range(-8,8):\n",
      "    ts = ToneSequence(freqs=freqs,env=genv,\n",
      "                      intertone_delay=0.01,\n",
      "                      tone_duration=tone_duration)\n",
      "    ts.shift_tones(shift=interval**i)\n",
      "    context.List.append(ts)\n",
      "\n",
      "tritone = Tritone(fb=band_base[np.random.rand()>0.5],\n",
      "                  delay=0.1+context.getduration(),\n",
      "                  duration_sp=tone_duration,\n",
      "                  delay_sp=0.05,\n",
      "                  env=genv)\n",
      "    \n",
      "    \n",
      "scene.addItemToList(context)\n",
      "scene.addItemToList(tritone)\n",
      "\n",
      "scene.draw_spectrogram()\n",
      "x = scene.generate(fs=fs)\n",
      "print x.shape\n",
      "\n",
      "display(Audio(x, rate=fs, autoplay=True))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "## Generating independent Uniform banded streams of tones \n",
      "\n",
      "context = Node(List=[])\n",
      "band=band_base\n",
      "\n",
      "\n",
      "for i in range(-8,8):\n",
      "    band=[fmin*interval**i, fmax*interval**i]\n",
      "    ts = UniformToneSequence(n_tones=n_tones,\n",
      "                             tone_duration=tone_duration,\n",
      "                             intertone_delay=0.,\n",
      "                             band=band,\n",
      "                             env=genv)\n",
      "    context.List.append(ts)\n",
      "\n",
      "tritone = Tritone(fb=band_base[np.random.rand()>0.5],\n",
      "                  delay=0.1+context.getduration(),\n",
      "                  duration_sp=tone_duration,\n",
      "                  delay_sp=0.05,\n",
      "                  env=genv)\n",
      "\n",
      "scene = Scene(List=[])    \n",
      "scene.addItemToList(context)\n",
      "scene.addItemToList(tritone)\n",
      "\n",
      "scene.draw_spectrogram()\n",
      "x = scene.generate(fs=fs)\n",
      "print x.shape\n",
      "\n",
      "display(Audio(x, rate=fs, autoplay=True))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# Opposing coherent vs non-coherent contexts\n",
      "\n",
      "fmin = 100.+50*np.random.rand()\n",
      "fmax = fmin*np.sqrt(interval)\n",
      "band_base = [fmin,fmax]\n",
      "band = band_base\n",
      "\n",
      "#-----------------------------\n",
      "context1 = Node(List=[])\n",
      "freqs = list( band[0]* (band[1]/band[0])**np.random.rand(n_tones,)  )\n",
      "for i in range(-5,5):\n",
      "    ts = ToneSequence(freqs=freqs,env=genv,\n",
      "                      intertone_delay=0.,\n",
      "                      tone_duration=tone_duration)\n",
      "    ts.shift_tones(shift=interval**i)\n",
      "    context1.List.append(ts)\n",
      "    \n",
      "#-----------------------------\n",
      "context2 = Node(List=[])\n",
      "for i in range(-5,5):\n",
      "    band=[fmin*np.sqrt(2)*interval**(i), fmax*np.sqrt(2)*interval**(i)]\n",
      "    ts = UniformToneSequence(n_tones=n_tones,\n",
      "                             tone_duration=tone_duration,\n",
      "                             intertone_delay=0.,\n",
      "                             band=band,\n",
      "                             env=genv)\n",
      "    context2.List.append(ts)\n",
      "    \n",
      "#------------------------------\n",
      "\n",
      "d = np.random.rand()>0.5\n",
      "d = 0\n",
      "print 'd=',d\n",
      "tritone = Tritone(fb=band_base[d],\n",
      "                  delay=0.1+context.getduration(),\n",
      "                  duration_sp=tone_duration,\n",
      "                  delay_sp=0.05,\n",
      "                  env=genv)\n",
      "\n",
      "scene = Scene(List=[])    \n",
      "scene.addItemToList(context1)\n",
      "scene.addItemToList(context2)\n",
      "scene.addItemToList(tritone)\n",
      "\n",
      "scene.draw_spectrogram()\n",
      "x = scene.generate(fs=fs)\n",
      "print x.shape\n",
      "\n",
      "display(Audio(x, rate=fs, autoplay=True))"
     ],
     "language": "python",
     "metadata": {},
     "outputs": []
    }
   ],
   "metadata": {}
  }
 ]
}
{'fraction_non_alphanumeric': 0.20977641385357298, 'fraction_numerical': 0.02367382726874178, 'mean_word_length': 1.8596051394547164, 'pattern_counts': {'":': 76, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4601464', 'n_tokens_mistral': 3505, 'n_tokens_neox': 3338, 'n_words': 469}