Monday, October 16, 2017

Tone JS UI/UX Project Buffer Shuffler

https://tonejs.github.io/docs/

Tone.Buffer

↳ EXTENDS Tone
Buffer loading and storage. Tone.Buffer is used internally by all classes that make requests for audio files such as Tone.Player, Tone.Sampler and Tone.Convolver. Aside from load callbacks from individual buffers, Tone.Buffer provides events which keep track of the loading progress of all of the buffers. These are Tone.Buffer.on(“load” / “progress” / “error”)

CONSTRUCTOR

new Tone.Buffer ( 
url
 , [ 
onload
 ] , [ 
onerror
 ] )
url
The url to load, or the audio buffer to set.
TYPE: AudioBuffer OR String
onload
A callback which is invoked after the buffer is loaded. It’s recommended to use Tone.Buffer.on('load', callback) instead since it will give you a callback when all buffers are loaded.
TYPE: Function
OPTIONAL
onerror
The callback to invoke if there is an error
TYPE: Function
OPTIONAL

DEFAULTS

{
url : undefined ,
reverse : false
}

EXAMPLE

var buffer = new Tone.Buffer("path/to/sound.mp3", function(){
 //the buffer is now available.
 var buff = buffer.get();
});
 

EXAMPLE

//can load provide fallback extension types if the first type is not supported.
var buffer = new Tone.Buffer("path/to/sound.[mp3|ogg|wav]");

MEMBERS

.duration

 ↝ Number READONLY #
The duration of the buffer.

.length

 ↝ Number READONLY #
The length of the buffer in samples

.loaded

 ↝ Boolean READONLY #
If the buffer is loaded or not

.numberOfChannels

 ↝ Number READONLY #
The number of discrete audio channels. Returns 0 if no buffer is loaded.

.reverse

 ↝ Boolean #
Reverse the buffer.

METHODS

.dispose ( )

 #
↪ RETURNS Tone.Buffer
this
dispose and disconnect

.fromArray ( )

 #
array
The array to fill the audio buffer
TYPE: Float32Array
↪ RETURNS Tone.Buffer
this
Set the audio buffer from the array. To create a multichannel AudioBuffer, pass in a multidimensional array.

.get ( )

 #
↪ RETURNS AudioBuffer
The audio buffer stored in the object.

.getChannelData ( )

 #
channel
The channel number to return
TYPE: Number
↪ RETURNS Float32Array
The audio as a TypedArray
Returns the Float32Array representing the PCM audio data for the specific channel.

.load ( )

 #
url
The url of the buffer to load. filetype support depends on the browser.
TYPE: String
↪ RETURNS Promise
returns a Promise which resolves with the Tone.Buffer
Makes an xhr reqest for the selected url then decodes the file as an audio buffer. Invokes the callback once the audio buffer loads.

.set ( )

 #
buffer
the buffer
TYPE: AudioBuffer OR Tone.Buffer
↪ RETURNS Tone.Buffer
this
Pass in an AudioBuffer or Tone.Buffer to set the value of this buffer.

.slice ( )

 #
start
The time to start the slice
TYPE: Time
end
The end time to slice. If none is given will default to the end of the buffer
TYPE: Time
OPTIONAL
↪ RETURNS Tone.Buffer
this
Cut a subsection of the array and return a buffer of the subsection. Does not modify the original buffer

.toArray ( )

 #
channel
Optionally only copy a single channel from the array.
TYPE: Number
OPTIONAL
↪ RETURNS Array
Get the buffer as an array. Single channel buffers will return a 1-dimensional Float32Array, and multichannel buffers will return multidimensional arrays.

.toMono ( )

 #
channel
Optionally only copy a single channel from the array.
TYPE: Number
OPTIONAL
↪ RETURNS Array
Sums muliple channels into 1 channel

STATIC METHODS

.cancelDownloads ( )

 #
↪ RETURNS Tone.Buffer
Stop all of the downloads in progress

.fromArray ( )

 #
array
The array to fill the audio buffer
TYPE: Float32Array
↪ RETURNS Tone.Buffer
A Tone.Buffer created from the array
Create a Tone.Buffer from the array. To create a multichannel AudioBuffer, pass in a multidimensional array.

.load ( )

 #
url
TYPE: String
onload
TYPE: Function
onerror
TYPE: Function
onprogress
TYPE: Function
↪ RETURNS XMLHttpRequest
Loads a url using XMLHttpRequest.

.supportsType ( )

 #
url
The url/extension to test
TYPE: String
↪ RETURNS Boolean
If the file extension can be played
Checks a url’s extension to see if the current browser can play that file type.

EXAMPLE

Tone.Buffer.supportsType("wav"); //returns true
Tone.Buffer.supportsType("path/to/file.wav"); //returns true

TUMBLR PROJECT -- TBD

https://github.com/tumblr/tumblr.js


Build Status
The official JavaScript client library for the Tumblr API. Check out the detailed documentation here.

Installation

Install this package from npm:
npm install --save tumblr.js

Usage

Authentication

Different API methods use different kinds of authentication.
Most of them require at least an API key, which will require you to register an application. The OAuth Consumer Key is your API key.
For methods that require a fully signed request, you'll need OAuth tokens as well, which you get from authenticating as a Tumblr user and allowing access to your API application. Here's the easy way to do it with our own account:
  1. Visit the OAuth applications page
  2. Click "Explore API" on the application you want to authorize
  3. Click the "Allow" button, which will take you to the API console
  4. Click the "Show keys" button, which will show you the credentials you can use to make signed requests.
If you're building an application of your own for users out in the world, you'll need to go through the 3-legged OAuth flow. See the help docs for more info.

In Node.js

var tumblr = require('tumblr.js');
var client = tumblr.createClient({
  consumer_key: '<consumer key>',
  consumer_secret: '<consumer secret>',
  token: '<oauth token>',
  token_secret: '<oauth token secret>'
});
Or, if you prefer:
var tumblr = require('tumblr.js');
var client = new tumblr.Client({
  // ...
});
The request methods return Request objects by default, but you can have it return Promise objects instead, if that's more your thing. Pass returnPromises: true in the options to createClient:
var tumblr = require('tumblr.js');
var client = tumblr.createClient({
  credentials: {
    // ...
  },
  returnPromises: true,
});

In the Browser

Due to CORS restrictions, you're going to have a really hard time using this library in the browser. Although GET endpoints on the Tumblr API support JSONP, this library is not intended for in-browser use. Sorry!

Example

// Show user's blog names
client.userInfo(function(err, data) {
  data.user.blogs.forEach(function(blog) {
    console.log(blog.name);
  });
});

Supported Methods

Below is a list of available methods and their purpose. Available options are documented in the API Docs and are specified as a JavaScript object.
client.blogPosts('staff', {type: 'photo'}, function(err, resp) {
  resp.posts; // use them for something
});
In most cases, since options are optional (heh) they are also an optional argument, so there is no need to pass an empty object when supplying no options, like:
client.blogPosts('staff', function(err, resp) {
  resp.posts; // now we've got all kinds of posts
});
If you're using Promises, use then and/or catch instead of a callback:
client.blogPosts('staff')
  .then(function(resp) {
    resp.posts;
  })
  .catch(function(err) {
    // oops
  });

User Methods

// Get information about the authenticating user & their blogs
client.userInfo(callback);

// Get dashboard for authenticating user
client.userDashboard(options, callback);
client.userDashboard(callback);

// Get likes for authenticating user
client.userLikes(options, callback);
client.userLikes(callback);

// Get followings for authenticating user
client.userFollowing(options, callback);
client.userFollowing(callback);

// Follow or unfollow a given blog
client.followBlog(blogURL, callback);
client.unfollowBlog(blogURL, callback);

// Like or unlike a given post
client.likePost(id, reblogKey, callback);
client.unlikePost(id, reblogKey, callback);

Blog Methods

// Get information about a given blog
client.blogInfo(blogName, callback);

// Get a list of posts for a blog (with optional filtering)
client.blogPosts(blogName, options, callback);
client.blogPosts(blogName, callback);

// Get the avatar URL for a blog
client.blogAvatar(blogName, size, callback);
client.blogAvatar(blogName, callback);

// Get the likes for a blog
client.blogLikes(blogName, options, callback);
client.blogLikes(blogName, callback);

// Get the followers for a blog
client.blogFollowers(blogName, options, callback);
client.blogFollowers(blogName, callback);

// Get the queue for a blog
client.blogQueue(blogName, options, callback);
client.blogQueue(blogName, callback);

// Get the drafts for a blog
client.blogDrafts(blogName, options, callback);
client.blogDrafts(blogName, callback);

// Get the submissions for a blog
client.blogSubmissions(blogName, options, callback);
client.blogSubmissions(blogName, callback);

Post Methods

// Edit a given post
client.editPost(blogName, options, callback);

// Reblog a given post
client.reblogPost(blogName, options, callback);

// Delete a given post
client.deletePost(blogName, id, callback);

// Convenience methods for creating post types
client.createTextPost(blogName, options, callback);
client.createPhotoPost(blogName, options, callback);
client.createQuotePost(blogName, options, callback);
client.createLinkPost(blogName, options, callback);
client.createChatPost(blogName, options, callback);
client.createAudioPost(blogName, options, callback);
client.createVideoPost(blogName, options, callback);

Tagged Methods

// View posts tagged with a certain tag
client.taggedPosts(tag, options, callback);
client.taggedPosts(tag, callback);

Unsupported Methods

You can make GET and POST requests to any endpoint directly. These methods are used internally by the methods listed above:
// GET requests
client.getRequest(apiPath, params, callback);

// POST requests
client.postRequest(apiPath, params, callback);
In the unlikely event that we add a bunch of methods to the API docs and don't update this client, you can map new client methods to API endpoints. URL and query parameters are automatically turned into arguments to these methods. It's a little weird to explain, so just look at these examples:
// GET methods
client.addGetMethods({
  // creates client.userInfo(params, callback)
  userInfo: '/user/info',
  // client.blogInfo(blogIdentifier, params, callback)
  blogInfo: '/blog/:blogIdentifier/info',
  // Creates client.taggedPosts(tag, params, callback)
  taggedPosts: ['/tagged', ['tag']],
});

// POST methods
client.addPostMethods({
  // client.deletePost(blogIdentifier, id, params, callback)
  deletePost: ['/blog/:blogIdentifier/post/delete', ['id']],
  // Creates client.likePost(tag, id, reblog_key, params, callback)
  likePost: ['/user/like', ['id', 'reblog_key']],
});

Running Tests

npm test # linter and tests
gulp lint # linter
gulp test # just the tests

Scripting for the Web Final

I spent a lot of time working on my updated portfolio website this semester. Here's an excerpt of the reflection post I wrote (because t...