logo

bytemedia

Home to byte-level sounds, images, videos, … git clone https://anongit.hacktivis.me/git/bytemedia.git/

instruments.h (528B)


  1. #ifndef _XOPEN_SOURCE
  2. #warning Should #define _XOPEN_SOURCE 700
  3. #define _XOPEN_SOURCE 700
  4. #endif
  5. #include <math.h> // sinf(), M_PI
  6. float
  7. pure_sin(struct au_header *header, int hertz, int t)
  8. {
  9. float w1 = 2*M_PI*hertz/header->samplerate;
  10. return sinf(w1*t);
  11. }
  12. float
  13. clarinet(struct au_header *header, int hertz, int t)
  14. {
  15. float w1 = 2*M_PI*hertz/header->samplerate;
  16. float tune = sin(w1*t) + 0.75*sin(3*w1*t) + 0.5*sin(5*w1*t) + 0.14*sin(7*w1*t) + 0.5*sin(9*w1*t) + 0.12*sin(11*w1*t) + 0.17*sin(13*w1*t);
  17. return tune/10;
  18. }