config.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #define STUNESVERSION 0.1
  2. #define PI 3.14159265358979323846
  3. #define MAKEITWAVY(freq) (2*(PI/freq))
  4. /* CHANGE HERE */
  5. /* wave symbols */
  6. /* wconstant wsine wcosine wtan */
  7. enum wav { wcon, wsin, wcos, wtan };
  8. /* data types */
  9. typedef struct {
  10. char* seq;
  11. enum wav type;
  12. int freq;
  13. } rhythm;
  14. typedef struct {
  15. int factor;
  16. } payload;
  17. /* wave function definitions */
  18. #define RETTYPE long
  19. RETTYPE wconf(payload);
  20. RETTYPE wsinf(payload);
  21. RETTYPE wcosf(payload);
  22. RETTYPE wtanf(payload);
  23. RETTYPE (*resolve(enum wav))(payload);
  24. /* ^ resolve takes a wave type and returns the appropriate function following */
  25. /* the format 'RETTYPE func(payload)' */
  26. /* wave function implementations */
  27. RETTYPE wconf(payload p)
  28. {
  29. return (RETTYPE)p.factor;
  30. }
  31. RETTYPE wsinf(payload p)
  32. {
  33. return sinf(MAKEITWAVY(p.factor) * p.factor);
  34. }
  35. RETTYPE wcosf(payload p)
  36. {
  37. return cosf(MAKEITWAVY(p.factor) * p.factor);
  38. }
  39. RETTYPE wtanf(payload p)
  40. {
  41. return tanf(MAKEITWAVY(p.factor) * p.factor);
  42. }
  43. RETTYPE (*resolve(enum wav wavetype))(payload p)
  44. {
  45. return &wtanf;
  46. }
  47. // TODO: think about the rationale of imposing a channel limit
  48. static rhythm channels[8];
  49. /* comment, newline, freq, method, rhythm, ignore */
  50. static char symbols[6] = { '#', '\n', 'f', 'm', 'r', '-' };
  51. /* RESERVED */