Show More
@@ -1,6 +1,6 b'' | |||||
1 | { |
|
1 | { | |
2 | "metadata": { |
|
2 | "metadata": { | |
3 | "name": "Part 5 - Rich Display System" |
|
3 | "name": "" | |
4 | }, |
|
4 | }, | |
5 | "nbformat": 3, |
|
5 | "nbformat": 3, | |
6 | "nbformat_minor": 0, |
|
6 | "nbformat_minor": 0, | |
@@ -500,6 +500,60 b'' | |||||
500 | "level": 2, |
|
500 | "level": 2, | |
501 | "metadata": {}, |
|
501 | "metadata": {}, | |
502 | "source": [ |
|
502 | "source": [ | |
|
503 | "Audio" | |||
|
504 | ] | |||
|
505 | }, | |||
|
506 | { | |||
|
507 | "cell_type": "markdown", | |||
|
508 | "metadata": {}, | |||
|
509 | "source": [ | |||
|
510 | "IPython makes it easy to work with sounds interactively. The `Audio` display class allows you to create an audio control that is embedded in the Notebook. The interface is analogous to the interface of the `Image` display class. All audio formats supported by the browser can be used. Note that no single format is presently supported in all browsers." | |||
|
511 | ] | |||
|
512 | }, | |||
|
513 | { | |||
|
514 | "cell_type": "code", | |||
|
515 | "collapsed": false, | |||
|
516 | "input": [ | |||
|
517 | "from IPython.display import Audio\n", | |||
|
518 | "Audio(url=\"http://www.nch.com.au/acm/8k16bitpcm.wav\")" | |||
|
519 | ], | |||
|
520 | "language": "python", | |||
|
521 | "metadata": {}, | |||
|
522 | "outputs": [] | |||
|
523 | }, | |||
|
524 | { | |||
|
525 | "cell_type": "markdown", | |||
|
526 | "metadata": {}, | |||
|
527 | "source": [ | |||
|
528 | "A Numpy array can be auralized automatically. The Audio class normalizes and encodes the data and embed the result in the Notebook.\n", | |||
|
529 | "\n", | |||
|
530 | "For instance, when two sine waves with almost the same frequency are superimposed a phenomena known as [beats](https://en.wikipedia.org/wiki/Beat_%28acoustics%29) occur. This can be auralised as follows" | |||
|
531 | ] | |||
|
532 | }, | |||
|
533 | { | |||
|
534 | "cell_type": "code", | |||
|
535 | "collapsed": false, | |||
|
536 | "input": [ | |||
|
537 | "import numpy as np\n", | |||
|
538 | "max_time = 3\n", | |||
|
539 | "f1 = 220.0\n", | |||
|
540 | "f2 = 224.0\n", | |||
|
541 | "rate = 44100.0\n", | |||
|
542 | "L = 3\n", | |||
|
543 | "times = np.linspace(0,L,rate*L)\n", | |||
|
544 | "signal = np.sin(2*np.pi*f1*times) + np.sin(2*np.pi*f2*times)\n", | |||
|
545 | "\n", | |||
|
546 | "Audio(data=signal, rate=rate)" | |||
|
547 | ], | |||
|
548 | "language": "python", | |||
|
549 | "metadata": {}, | |||
|
550 | "outputs": [] | |||
|
551 | }, | |||
|
552 | { | |||
|
553 | "cell_type": "heading", | |||
|
554 | "level": 2, | |||
|
555 | "metadata": {}, | |||
|
556 | "source": [ | |||
503 | "Video" |
|
557 | "Video" | |
504 | ] |
|
558 | ] | |
505 | }, |
|
559 | }, | |
@@ -1237,4 +1291,4 b'' | |||||
1237 | "metadata": {} |
|
1291 | "metadata": {} | |
1238 | } |
|
1292 | } | |
1239 | ] |
|
1293 | ] | |
1240 | } |
|
1294 | } No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now