Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does "tsw.load" work? #28

Open
DavidSabine opened this issue Jul 5, 2014 · 3 comments
Open

Does "tsw.load" work? #28

DavidSabine opened this issue Jul 5, 2014 · 3 comments

Comments

@DavidSabine
Copy link

Calling tsw.load as described here http://theresassoundworld.com/#load doesn't appear to work. The arguments are not parsed into arrays and objects which are compatible with the loadFile function.

For example, at line 589 ("number_of_files = Object.keys(files).length;"), the number_of_files will always equal 1 (if isArray(files) === true).

My REAL question: is tsw.load known to actually work currently? If so, I'll debug MY code -- if not, I'll debug tsw.load and submit a pull request.

@stuartmemo
Copy link
Owner

Oh, let me look into it. Maybe the documentation isn't right. It currently works as in the tests:

https://github.com/stuartmemo/theresas-sound-world/blob/master/tests/tests.js

Starts line 352.

Saying that, would love your feedback on what syntax you prefer on loading files. I'm not 100% on what I've done.

@DavidSabine
Copy link
Author

Hi Stuart,

I did see your tests.js file -- it appears that you're testing the tsw.load function with only two arguments:

    describe('Load files', function () {
        var my_success;
        it('Load some mp3s', function (done) {
            tsw.load({
                files: {
                    sampleOne: 'samples/tsw1.mp3',
                    sampleTwo: 'samples/tsw2.mp3',
                    sampleThree: 'samples/tsw3.mp3',
                }
            }, function (success) {
                my_success = success;
                done();
            });
        });

Though the documentation http://theresassoundworld.com/#load allows for three args (the second being "path"):

tsw.load(
{
talking: 'talking-sample.mp3',
singing: 'my-lovely-singing.mp3'
},
{
path: '/path/to/files/'
},
function (response, status, xhr) {
if (status === 'success') {
// Files have loaded successfully
tsw.play(response.talking);
} else {
// There's been an error
console.log('We have a technical: ' + xhr.statusText);
}
}
);

Being able to define a path may be helpful, though not essential.

As far as syntax is concerned, I like what you've designed but I'm currently unclear how I can access the buffers after they're loaded -- that is, I'm not currently understanding how I can pass buffers to tsw.play() when I'm not inside the successCallback function. I think I should want access to an array of buffers that are available in the current audioContext -- maybe you've already implemented something this and I simply need to study more. I have something like this in mind (totally over-simplified, please forgive me):

// on DOMContentLoaded I'd like to load some buffers like:
var tsw.buffers = new Array();
tsw.buffers = tsw.load(anArrayOfUrls);

// at any time, I'd like to be able to add new buffers, maybe like:
tsw.buffers.push(tsw.load(aStringOfUrl));

// at any time, I'd like to be able to control all or individual buffers - somewhat like audio objects (gain, etc.), and somewhat like an array (push, splice, pop, etc), maybe like:
tsw.buffers.play(aTime,booleanLoop);
tsw.buffers.pan(0);
tsw.buffers[0].pan(-1);
tsw.buffers.gain(0.3);
tsw.buffers.remove(tsw.buffers[0]);

PLEASE don't heed my input too much though. I have more trust in your JavaScript knowledge than my own.

@stuartmemo
Copy link
Owner

Ooh, that's a really good idea regarding the buffers. Currently you have to create a buffer using var my_buffer = tsw.buffer(); then assign the loaded buffer into my_buffer.

But like you say if buffers was a special array that converted a file into a playable buffer automatically then that'd be pretty nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants