Code it
4.6K views | +0 today
Follow
Code it
This is a curated resource for programmers and software architects. It is regularly updated with Articles, Hacks, How Tos, Examples and Code.
Curated by nrip
Your new post is loading...
Your new post is loading...
Scooped by nrip
Scoop.it!

Understanding the Web Audio API

Understanding the Web Audio API | Code it | Scoop.it

Understand more about the Web Audio API, an API that allows us to create and manage sounds in our browser very easily.

Web Audio API

Let’s start with the basics about the Web Audio API. This is how the API works:

  1. The Web Audio API has a main audio context.
  2. Inside that audio context, we can handle and manage our audio operations. The audio operations are handled by audio nodes.
  3. We can have a lot of different audio nodes inside the same audio context, allowing us to create some nice things such as drum kits, synthesizers, etc.

Let’s create our first audio context using the Web Audio API and start to make some noise in our browser. This is how you can create an audio context:

const audioContext = new (window.AudioContext || window.webkitAudioContext);
 

The audio context is an object that contains all stuff audio related. It’s not a good idea to have more than one audio context in your project—this can cause you a lot of trouble in the future.

 

The Web Audio API has an interface called OscillatorNode. This interface represents a periodic waveform, pretty much a sine wave. Let’s use this interface to create some sound.

Now that we have our audioContext const initiating the audio context, let’s create a new const called mySound, passing the audioContext const and calling the createOscillator method, like this:

const mySound = audioContext.createOscillator();
 

We created our OscillatorNode, now we should start the mySound, like this:

mySound.start();
 

But, as you can see, it’s not playing anything in your browser. Why? We create our audioContext const initiating the audio context, but we didn’t pass any destination to it. We should always pass a property called destination to our audioContext const, otherwise, it won’t work.

So, now, just use the mySound const, call a method called connect and pass our audioContext.destination, like this:

mySound.connect(audioContext.destination);
 

Now we’re using the Web Audio API to very easily create noises in our browser.

Properties

The OscillatorNode has some properties, such as type. The type property specifies the type of waveform that we want our OscillatorNode to output. We can use 5 forms of output: sine (default), square, sawtooth, triangle and custom.

To change the type of our OscillatorNode, all we must do is pass after the start() method a type to our mySound, like this:

mySound.type = "square"
 

The OscillatorNode also has another property called frequency. We can use this property to represent the oscillation of our OscillatorNode in hertz.

To change the oscillation of our OscillatorNode in hertz, we must call the frequency property, and call the setValueAtTime function. This function receives two arguments: the value in hertz and our audio context. We can use it like this:

mySound.frequency.setValueAtTime(400, audioContext.currentTime);
 

By using the Web Audio API, we can manage audio pretty easily now in our browsers, but if you’re wanting to use this API to create something more difficult and powerful, you’ll probably need to use a library for it.

 

read the entire article including the details on how to use Howler at https://www.telerik.com/blogs/understanding-web-audio-api

 

 

No comment yet.
Scooped by nrip
Scoop.it!

How to Use the Animation Inspector in Chrome Developer Tools

How to Use the Animation Inspector in Chrome Developer Tools | Code it | Scoop.it

Next time you’re putting together some CSS3-based animations you might find it helpful to jump into Chrome Developer Tools and take advantage of its animation inspection and tweaking features.

 

In this quick tip Kezz Bracey will give you a rundown of which animation dev tools are available in Chrome, how to access them, and what they can do for you.

 

see the article at https://webdesign.tutsplus.com/articles/quick-tip-chrome-animation-dev-tools--cms-31505?ref=ewebdesign.com

 

 

No comment yet.
Scooped by nrip
Scoop.it!

Beginner's Guide to React Redux

Beginner's Guide to React Redux | Code it | Scoop.it

There are several states in a JavaScript web app that keep on changing on the basis of user behavior, time, and other reasons. For example, creating a new to-do item in a ‘To Do list’ app will eventually change the current state of the application to the new state with the to-do item involved.

 

Since the state of the application is changed, the view through which the current state is presented with changes, and it eventually allows users to see the new to-do item in their view. However, if the state of an application doesn’t behave as expected, then it’s possibly the right time to debug the app.

 

Redux framework is a way to manage the  complete state of a JavaScript application through a centralized interface. In Redux each component of a web app can directly access the application’s state without sending down the props to child components.

 

Redux is a conventional state container for JavaScript applications. This state management tool is frequently used with the React JavaScript library, and it helps build web applications that can easily operate in different environments and behave consistently. 

 

Redux has a large ecosystem of add-ons that ultimately makes it suitable to be used together with React website templates as well as other view libraries. On top of all that, React Redux can easily provide a great and dynamic developer experience, along with many amazing benefits. 

 

Read the tutorial at :

 

https://www.wrappixel.com/beginners-guide-to-react-redux-heres-how-to-get-started/

 

to learn about

 

  1. How does the Redux framework work?
  2. Basics of React Redux
  3. Action(s)
  4. Reducer(s)
  5. Action Type
  6. Redux Store
  7. Simple Styling for React Redux Components
  8. Integrating React Redux within a User interface
  9. Why do developers prefer React Redux?
  10. Why should you use Redux?
  11. The way forward: The best online tutorials to master Redux from scratch.

 

 

No comment yet.