wav file volume control
I have a patch set up triggering an audio sample. the sfplay~ object is used to play a wav file. I want to be able to trigger the sample at different volumes depending on incoming acceleration values e.g. greater acceleration would result in a higher volume.
I’m looking for more of a hint really than just a straight forward answer. I’m not sure how to control the volume from the ezdac~. I tried to use the gain object but this didn’t seem to work. I’m sure if I knew how to alter the output volume I would be able to work out the rest!
Look into [adsr~] in conjunction with [*~]. You can scale an incoming
MIDI note’s velocity, for example, to drive the sustain portion of
On Mar 15, 2008, at 4:00 PM, Adam wrote:
> I have a patch set up triggering an audio sample. the sfplay~
> object is used to play a wav file. I want to be able to trigger the
> sample at different volumes depending on incoming acceleration
> values e.g. greater acceleration would result in a higher volume.
> I’m looking for more of a hint really than just a straight forward
> answer. I’m not sure how to control the volume from the ezdac~. I
> tried to use the gain object but this didn’t seem to work. I’m sure
> if I knew how to alter the output volume I would be able to work
> out the rest!
Steven M. Miller
Professor, Contemporary Music Program
College of Santa Fe
Home < http://pubweb.csf.edu/~smill>
SFIFEM < http://sfifem.csf.edu>
Atrium Sound Space < http://atrium.csf.edu>
OVOS < http://pubweb.csf.edu/~smill/ovos.html>
CMP < http://www.csf.edu/academics/contemporary_music/>
> I tried to use the gain object but this didn’t seem to work. I’m sure
> if I knew how to alter the output volume I would be able to work out
> the rest!
The knowledge you are missing is in the tutorials. The gain object does
work (as does *~, adsr~, line~… they all have help files as well…)
Here’s two ways to control the levels.
#P window setfont "Sans Serif" 9.;
#P window linecount 1;
#P newex 168 259 41 196617 * 0.01;
#P user uslider 168 148 41 85 100 1 0 0;
#P newex 89 300 41 196617 *~ 0.2;
#P user gain~ 484 161 24 100 158 0 1.071519 7.94321 10.;
#P user ezdac~ 477 364 521 397 0;
#P comment 391 220 100 196617 simple Gain way;
#P message 301 40 36 196617 set 1.;
#P flonum 301 67 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 247 58 14 196617 0;
#P message 230 58 14 196617 1;
#P message 199 58 30 196617 open;
#N sfplay~ 1 120960 0 ;
#P newobj 233 105 44 196617 sfplay~;
#P comment 47 210 100 196617 multiplier way;
#P window linecount 3;
#P comment 251 269 100 196617 makes range 0-1.0 from the 0-100 the slider outputs;
#P window linecount 1;
#P comment 339 67 100 196617 speed control;
#P fasten 3 0 12 0 238 138 94 138;
#P connect 3 0 11 0;
#P fasten 12 0 10 0 94 332 482 332;
#P fasten 12 0 10 1 94 319 516 319;
#P fasten 11 0 10 0 489 340 482 340;
#P fasten 11 0 10 1 489 340 516 340;
#P fasten 14 0 12 1 173 287 125 287;
#P connect 13 0 14 0;
#P connect 8 0 7 0;
#P connect 7 0 3 1;
#P connect 6 0 3 0;
#P connect 5 0 3 0;
#P connect 4 0 3 0;
#P window clipboard copycount 15;
basically the same results.
I understand wanting to jump right in Max and do cool stuff, hell, I’m still slowly going through them, damn thing called work keeps getting in the way for me. :)
I had an "Ah ha!" moment this weekend with Max. Once I accepted that the help files are really a HUGE help in learning how the objects work (and a great "cheater’s" tool), and that the help files don’t contain all the info many objects. That’s where the reference manuals come in super handy showing you all the more techy info on attributes and settings the help files may not show.
So in this moment of hypocrisy, The tutorials and help files really are your best friends in learning Max.
Hope the patch helps. Yay, I finally get to post a patch to try to help someone. :)
I can’t find a way to do this properly. Basically I aim to recreate the effect of mapping acceleration values to midi note velocity E.g. the greater the incoming acceleration value the greater midi note velocity and therefore the louder the midi note played.
I know how to do this using midi, but I want to create the same effect using a wav soundfile instead. At the moment I have a soundfile being triggered at one constant volume, but I want the output to be altered depending on the incoming acceleration force.
Thanks, but I’m not completely sure of what the the post above post is showing…getting a bit confused with which objects are plugged into other inlets etc. Could you explain please.
After implementing the map described in the posts above I have run into yet another problem. The incoming acceleration data that is mapped to the output amplitude is constantly changing, so the output of the wav file being played is altered several times before it finishes playing, which sounds unnatural. I’m not sure how to get around this problem.
I have tried using peak, to give the maximum acceleration value after each time the acceleration device is in motion, but once a maximum was calculated, peak could not be reset without affecting the output during the next motion.Is there a way round this? Possibly using average?Please help me!
On Mar 31, 2008, at 3:54 PM, Adam wrote:
> After implementing the map described in the posts above I have run
> into yet another problem. The incoming acceleration data that is
> mapped to the output amplitude is constantly changing, so the output
> of the wav file being played is altered several times before it
> finishes playing, which sounds unnatural. I’m not sure how to get
> around this problem.
Why don’t you post what you have? People can help better that way.
managed to rectify the problem in the end! cheers!