<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Linda Eng on Medium]]></title>
        <description><![CDATA[Stories by Linda Eng on Medium]]></description>
        <link>https://medium.com/@90lineng?source=rss-775670a831c9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*3f7-Ii8T_DkgXOd7.</url>
            <title>Stories by Linda Eng on Medium</title>
            <link>https://medium.com/@90lineng?source=rss-775670a831c9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 11:09:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@90lineng/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to use Tone.js with your React project]]></title>
            <link>https://medium.com/@90lineng/how-to-use-tone-js-with-your-react-project-3019f4b2b002?source=rss-775670a831c9------2</link>
            <guid isPermaLink="false">https://medium.com/p/3019f4b2b002</guid>
            <category><![CDATA[tonejs]]></category>
            <category><![CDATA[music]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[production]]></category>
            <dc:creator><![CDATA[Linda Eng]]></dc:creator>
            <pubDate>Fri, 10 Jul 2020 22:46:04 GMT</pubDate>
            <atom:updated>2020-07-10T22:48:37.664Z</atom:updated>
            <content:encoded><![CDATA[<h3>What exactly is Tone.js?</h3><p>Tone.js is an incredible framework that makes creating music on the browser seamless and accessible for developers. Tone.js is built on top of the <em>Web Audio API</em> and provides advanced scheduling capabilities, synths and effects, and much more in the realm of audio programming.</p><h3>How does the Web Audio API work?</h3><p>At the core of the Web Audio API, it has a number of various audio inputs, processors, and outputs, which you can combine into an audio graph that creates the sounds that you want.</p><p>A more abstracted description for the Web Audio API can be represented with an electric guitar set up. The guitar can be thought as the input which from their pickups, form the sound input which generates an audio signal. This signal travels to optional effect panels that modify this signal until it finally reaches the amp which outputs the sound</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oiWKypCCyng_chDSysPv4w.png" /></figure><p>Creating sound using the Web Audio API is synonymous to the guitar set up. To create any sound using the Web Audio API, you would construct an audio signal graph by using inputs, outputs, and any number of processing nodes in between. Tone.js abstracts a lot of the capabilities from the Web Audio API, making this framework a lot easier to work with.</p><p><em>For more documentation on the Web Audio API visit: </em><a href="https://webaudio.github.io/web-audio-api/#APIOverview"><em>https://webaudio.github.io/web-audio-api/#APIOverview</em></a></p><p>For more documentation on Tone.js visit: <a href="https://tonejs.github.io/">https://tonejs.github.io/</a></p><h3>Lets get started!</h3><p>Make sure you have Node.js installed and a text editor. If you’re not sure how to install node and npm, here is a link that will help you get started with setting up:</p><p><strong>Node</strong> : <a href="https://www.npmjs.com/get-npm">Download node and npm</a></p><p><strong>Visual Studio Code</strong>: <a href="https://code.visualstudio.com/">Download Visual Studio Code</a></p><p>We will create a project called tone-demo by running the following command:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*Y5poCfGiD5pBWpxhDHGneA.png" /></figure><p>Cd into the tone-demo folder. To set up Tone.js with your react project, begin by <em>npm install tone</em> to your project</p><p><a href="https://www.npmjs.com/package/tone">Link to Tone.js on npm</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*RxEDhhdPHMQFYTeV0jFZZA.png" /></figure><p>Check your package.json to make sure tone is installed:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*M3e4f7uqUlb0BMDmsJAqww.png" /></figure><p>Once installed, lets finally create our first synth using Tone.js!</p><h3>Basic Examples:</h3><p>Let’s work inside our App.js file. Import tone:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/837/1*M5uFrQhcIDSx39OVmXV7UA.png" /><figcaption>From: <a href="https://github.com/Tonejs/Tone.js">https://github.com/Tonejs/Tone.js</a></figcaption></figure><p>Now that you have tone imported, lets learn about the basics of Tone.js. To get started, you have to create a new synth(our instrument) and then connect it to the master(our speakers)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/738/1*-J7r-qsqpGKRbkE3qxImMA.png" /></figure><p>All instruments are instances of the Tone constructor. Tone.Synth is a basic synthesizer with a single envelope and single oscillator. There are more options for synths on <a href="https://tonejs.github.io/docs/">https://tonejs.github.io/docs/</a></p><p>Next we will create a function that will play a sound and to play it for an extended period of time. In order for our synth to generate sound, we need to include a triggerAttackRelease method on our Synth.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*9uvuLQ6jVrOj96CEYfy82g.png" /></figure><p><strong>triggerAttackRelease </strong>will allow us to trigger a note, and to play a note for a defined amount of time. This method takes in two arguments. The first argument will take in a string that will be the note that we are playing. If you want to play middle ‘C’ for an 8th note count, you will write ‘C4’ into the first argument and ‘8n’ for the second argument.</p><p>Let’s create a button that will trigger our synth, playing the note D on the 4th octave for an 8th note count:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/863/1*5zLu494tHCpOqfXjX6jJVg.png" /></figure><p>We can add some basic styling to get this button to be visible on our page:</p><p>Let’s navigate to our App.css and style the div and button with the following styles:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/408/1*F1hGKiB_HYdc9bwravZwQw.png" /></figure><p>Now lets test our results. Type <strong>npm run start </strong>in our terminal and we should see the following on localhost:3000 :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2ZxfTgGwsTgFZq2OEb2W4A.png" /></figure><p>Click the button and you should hear our MembraneSynth fire! Congrats you built your first synth using Tone.js.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3019f4b2b002" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>