You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
660 B
37 lines
660 B
4 years ago
|
#pragma once
|
||
|
#ifndef DSY_MAYTRIG_H
|
||
|
#define DSY_MAYTRIG_H
|
||
|
|
||
|
#include <stdint.h>
|
||
|
#ifdef __cplusplus
|
||
|
|
||
|
namespace daisysp
|
||
|
{
|
||
|
/** Probabilistic trigger module
|
||
|
|
||
|
Original author(s) : Paul Batchelor
|
||
|
|
||
|
Ported from soundpipe by Ben Sergentanis, May 2020
|
||
|
*/
|
||
|
class Maytrig
|
||
|
{
|
||
|
public:
|
||
|
Maytrig() {}
|
||
|
~Maytrig() {}
|
||
|
/** probabilistically generates triggers
|
||
|
|
||
|
\param prob (1 always returns true, 0 always false)
|
||
|
|
||
|
\return given a probability 0 to 1, returns true or false.
|
||
|
*/
|
||
|
inline float Process(float prob)
|
||
|
{
|
||
|
return ((float)rand() / (float)RAND_MAX) <= prob ? true : false;
|
||
|
}
|
||
|
|
||
|
private:
|
||
|
};
|
||
|
} // namespace daisysp
|
||
|
#endif
|
||
|
#endif
|