| 38 | } |
| 39 | |
| 40 | GranulationNode::GranulationNode(AudioContext & ac) |
| 41 | : AudioScheduledSourceNode(ac, *desc()) |
| 42 | { |
| 43 | // Sample that will be granulated |
| 44 | grainSourceBus = setting("GrainSource"); |
| 45 | |
| 46 | // Windowing function that will be applied as an envelope to each grain during playback |
| 47 | windowFunc = setting("WindowFunction"); |
| 48 | windowFunc->setEnumeration(static_cast<int>(WindowFunction::bartlett), true); |
| 49 | |
| 50 | // Total number of grains that will be allocated |
| 51 | numGrains = param("NumGrains"); |
| 52 | |
| 53 | // Duration of each grain in seconds (currently fixed but ideally will be configurable per-grain) |
| 54 | grainDuration = param("GrainDuration"); |
| 55 | |
| 56 | // The min/max positional offset (given in a normalized 0-1 range) from which a grain should |
| 57 | // be sampled from grainSourceBus. These numbers are used to inform the range of a random |
| 58 | // number generator. |
| 59 | grainPositionMin = param("PositionMin"); |
| 60 | grainPositionMax = param("PositionMax"); |
| 61 | |
| 62 | // How fast the grain should play, given as a multiplier. Useful for pitch-shifting effects. |
| 63 | grainPlaybackFreq = param("PlaybackFrequency"); |
| 64 | |
| 65 | addOutput(std::unique_ptr<AudioNodeOutput>(new AudioNodeOutput(this, 1))); |
| 66 | |
| 67 | initialize(); |
| 68 | } |
| 69 | |
| 70 | GranulationNode::~GranulationNode() |
| 71 | { |
nothing calls this directly
no test coverage detected