mohayonao / timbre.js

JavaScript library for objective sound programming
http://mohayonao.github.io/timbre.js/
MIT License
963 stars 74 forks source link

'T("undefined") is not defined' console error message #22

Closed ghost closed 10 years ago

ghost commented 10 years ago

While trying to set the freq of a simple synth within a NoUiSlider function, timbre is printing a 'T("undefined") is not defined' error printed to the console.

When setting the freq explicitly as the below commented out line, there is no issue.

             var value = 0;
                    $(function(){
                        $('.slider').noUiSlider({
                            start: 40,
                            range: {
                                'min': 0,
                                'max': 500
                            }
                        });
                    });
                    $('.slider').on({
                        slide: function(){
                            value = $('#slider').val(); 
                                synth1.set({freq:value});
                                        // synth1.set({freq:500});
                        }
                    });

This may or may not be an issue with timbre.js. Please accept my apologies if not. Thank you for a wonderful library thus far.

http://refreshless.com/nouislider/

mohayonao commented 10 years ago

please tell me this output.

$('.slider').on({
  slide: function() {
    value = $('#slider').val();
    console.log(value); // <-- what is this value?
  }
});

and try this selector.

value = $('.slider').val();
ghost commented 10 years ago

Ah yes - I'm not sure how I missed that selector setting! Thank you for that, it resolved the undefined message.

Looking at the console I now see what the problem was, running the value through a parseInt made the required conversion [value = parseInt(value);]. It appears that T("sin", {freq:100, mul:0.5}).play(); didn't like to receiving floating points. Can synths be declared so that they can?

mohayonao commented 10 years ago

Doesn't parseInt return an Integer?

// convert to a Number from a String
value = Number(value);
// or
value = +value;
ghost commented 10 years ago

Yes it does. I just wasn't sure if you could .set objects via floating point numbers.

The main problems I'm having at the moment are web audio API integration on mobile, and the loading of audio files on mobile (Android), however I feel that's for another discussion.

The original issue was resolved, so will close.

Thanks!