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.

64 lines
2.0KB

  1. /* ----------------------------------------------------------------------------
  2. ProtoFaust
  3. ==========
  4. DSP prototyping in Faust for VCV Rack
  5. Copyright (c) 2019-2020 Martin Zuther (http://www.mzuther.de/) and
  6. contributors
  7. This program is free software: you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation, either version 3 of the License, or
  10. (at your option) any later version.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU General Public License for more details.
  15. You should have received a copy of the GNU General Public License
  16. along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. Thank you for using free software!
  18. ---------------------------------------------------------------------------- */
  19. // Converts 1 V/oct to frequency in Hertz.
  20. //
  21. // The conversion formula is: 440 * 2 ^ (volts - 0.75)
  22. // The factor 0.75 shifts 0 V to C-4 (261.6256 Hz)
  23. cv_pitch2freq(cv_pitch) = 440 * 2 ^ (cv_pitch - 0.75);
  24. // Converts frequency in Hertz to 1 V/oct.
  25. //
  26. // The conversion formula is: log2(hertz / 440) + 0.75
  27. // The factor 0.75 shifts 0 V to C-4 (261.6256 Hz)
  28. freq2cv_pitch(freq) = ma.log2(freq / 440) + 0.75;
  29. // Converts 200 mV/oct to frequency in Hertz.
  30. i_cv_pitch2freq(i_cv_pitch) = i_cv_pitch : internal2cv_pitch : cv_pitch2freq;
  31. // Converts frequency in Hertz to 200 mV/oct.
  32. freq2i_cv_pitch(freq) = freq : freq2cv_pitch : cv_pitch2internal;
  33. // Converts Eurorack's 1 V/oct to internal 200 mv/oct.
  34. cv_pitch2internal(cv_pitch) = cv_pitch / 5;
  35. // Converts internal 200 mv/oct to Eurorack's 1 V/oct.
  36. internal2cv_pitch(i_cv_pitch) = i_cv_pitch * 5;
  37. // Converts Eurorack's CV (range of 10V) to internal CV (range of 1V)
  38. cv2internal(cv) = cv / 10;
  39. // Converts internal CV (range of 1V) to Eurorack's CV (range of 10V)
  40. internal2cv(i_cv) = i_cv * 10;