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

Modulation issues #5

Closed
metaphorz opened this issue Feb 21, 2014 · 7 comments
Closed

Modulation issues #5

metaphorz opened this issue Feb 21, 2014 · 7 comments

Comments

@metaphorz
Copy link

It seemed right to create a new thread for this...issues with modulation outside of Sampler. I am including code below. modulation test #1 is along the lines of an example you gave - that works fine since modulation is specified inside of the Sampler.

However, I have 2 related issues with the code below it

Issue 1: I need to be able to modulate b (audio file) with a (random signal). just doing "c = Mul(a,b).connect()" is not working since presumably a is a Table and b is a Sampler. How do I get a handle on the "Table" inside of b so that the Mul works?

Issue 2: I will be dynamically changing table "a" as the code runs. This would seem to require a more complex audio graph since the "Mul" is happening only once?

// Begin Gibberish sound synthesis

Gibberish.init();
Gibberish.Time.export();
Gibberish.Binops.export();  

a = new Gibberish.Table({ amp: 1 });
var t = []
for( var i = 0; i < 1024; i++ ) { t[ i ] = Gibberish.rndf(-1,1) }
a.setTable( t )

/* Pitch modulation # 1 - works well
b = new Gibberish.Sampler({
file: 'ordinary.wav',
loops: true,
pitch: Abs( a )
}).connect();
*/

/* Amplitude modulation # 2 - no sound */
b = new Gibberish.Sampler({
file: 'ordinary.wav',
loops: true});

b.onload = function() {
b.note(1);
}
// I will be changing "a" dynamically in code but right now
// just trying to create a modulation of b using a

c = Mul(a,b).connect();
// no sound

@charlieroberts
Copy link
Collaborator

It looks like the output of the sampler ugen is stereo, and the Mul ugen only takes numeric inputs. I need to do a little more work on the sampler to fix this, but for now your last line can be:

c = Mul( a, Merge(b) ).connect()

... and you should get the results you're looking for. Merge just takes a stereo sample (which is an array) and sums the array members to create a mono sample (which is a number).

@metaphorz
Copy link
Author

Ok, this gets me part of the way. Here is what I have now:

preysampler = new Gibberish.Sampler({file:'resources/prey.wav'});
predatorsampler = new Gibberish.Sampler({file:'resources/predator.wav'}); 

preysampler.onload = function() {preysampler.note(1);};
predatorsampler.onload = function() {predatorsampler.note(1);};

preymodulated = Mul(preytable,Merge(preysampler)).connect();
predatormodulatd = Mul(predatortable,Merge(predatorsampler)).connect();

The problem is that I dynamically change "preytable" and "predatortable" as the user manipulates sliders. However, when the user does this, there is no change in the audio. If Binops operators such as "Mul" re-evaluated their inputs, then presumably the audio would also change when the arguments change.

Is there a way to enable this? As a specific example, suppose that after the above code, I change preytable via "preytable.setTable(somearray);". The preymodulated is not updated, right?

@charlieroberts
Copy link
Collaborator

This works fine for me... are you sure your reference to the array inside the table object isn't getting lost somewhere? You can always access the underlying array with preytable.getTable()

Here's example code that removes wavetable noise after two seconds by changing all the values in the wavetable array to 1.

a = new Gibberish.Table({ amp: 1 });

var t = []
for( var i = 0; i < 1024; i++ ) { t[ i ] = Gibberish.rndf(-1,1) }
a.setTable( t )

b = new Gibberish.Sampler({
  file: 'resources/predator1sec.wav',
  loops: true,
});

b.onload = function() { b.note(1); }

c = Mul( Merge(b),a ).connect();

Gibberish.future( function() {
  for( var i = 0; i < 1024; i++ ) { t[ i ] = 1 }
}, 88200 )

@charlieroberts
Copy link
Collaborator

Just to be clear, you should able to change the underlying array of a Table ugen at any time and immediately hear the results.

@metaphorz
Copy link
Author

Thank you — I’ll play with this. The “Mul” worked but maybe I could near here
its effect because of another reason … such as the signal magnitude being
near 1 for the modulator. I’ll get back after trials.
-p

On Feb 24, 2014, at 2:39 AM, charlieroberts [email protected] wrote:

Just to be clear, you should able to change the underlying array of a Table ugen at any time and immediately hear the results.


Reply to this email directly or view it on GitHub.

Paul Fishwick, PhD
Chair, ACM SIGSIM
Distinguished Chair of Arts & Technology
and Professor of Computer Science
Director, Creative Automata Laboratory
The University of Texas at Dallas
Arts & Technology
800 West Campbell Road, AT10
Richardson, TX 75080-3021
Home: utdallas.edu/atec/fishwick
Blog: creative-automata.com

@charlieroberts
Copy link
Collaborator

Not sure why this is still open :)

@metaphorz
Copy link
Author

Must have forgotten to close. P

Sent from my iPhone

Paul Fishwick, PhD
Chair, ACM SIGSIM
Distinguished University Chair of Arts & Technology and Professor of Computer Science
The University of Texas at Dallas
Arts & Technology
800 West Campbell Road, AT10
Richardson, TX 75080-3021

On Sep 16, 2014, at 6:54 PM, charlie roberts [email protected] wrote:

Not sure why this is still open :)


Reply to this email directly or view it on GitHub.

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