{"id":231513,"date":"2014-07-29T18:03:02","date_gmt":"2014-07-29T14:03:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=231513"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=231513","title":{"rendered":"<span class=\"post_title\">\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0430\u0443\u0434\u0438\u043e\u043f\u043b\u0430\u0433\u0438\u043d\u043e\u0432, \u0447\u0430\u0441\u0442\u044c 14<\/span>"},"content":{"rendered":"<div class=\"content html_format\">     \t\u0412\u0441\u0435 \u043f\u043e\u0441\u0442\u044b \u0441\u0435\u0440\u0438\u0438:<br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/224911\/\">\u0427\u0430\u0441\u0442\u044c 1. \u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430<\/a><br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/225019\/\">\u0427\u0430\u0441\u0442\u044c 2. \u0418\u0437\u0443\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430<\/a><br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/225457\/\">\u0427\u0430\u0441\u0442\u044c 3. VST \u0438 AU<\/a><br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/225751\/\">\u0427\u0430\u0441\u0442\u044c 4. \u0426\u0438\u0444\u0440\u043e\u0432\u043e\u0439 \u0434\u0438\u0441\u0442\u043e\u0440\u0448\u043d<\/a><br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/225755\/\">\u0427\u0430\u0441\u0442\u044c 5. \u041f\u0440\u0435\u0441\u0435\u0442\u044b \u0438 GUI<\/a><br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/226439\/\">\u0427\u0430\u0441\u0442\u044c 6. \u0421\u0438\u043d\u0442\u0435\u0437 \u0441\u0438\u0433\u043d\u0430\u043b\u043e\u0432<\/a><br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/226573\/\">\u0427\u0430\u0441\u0442\u044c 7. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 MIDI \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439<\/a><br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/226823\/\">\u0427\u0430\u0441\u0442\u044c 8. \u0412\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0430\u044f \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u0430<\/a><br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/227475\/\">\u0427\u0430\u0441\u0442\u044c 9. \u041e\u0433\u0438\u0431\u0430\u044e\u0449\u0438\u0435<\/a><br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/227601\/\">\u0427\u0430\u0441\u0442\u044c 10. \u0414\u043e\u0440\u0430\u0431\u043e\u0442\u043a\u0430 GUI<\/a><br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/227791\/\">\u0427\u0430\u0441\u0442\u044c 11. \u0424\u0438\u043b\u044c\u0442\u0440<\/a><br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/227827\/\">\u0427\u0430\u0441\u0442\u044c 12. \u041d\u0438\u0437\u043a\u043e\u0447\u0430\u0441\u0442\u043e\u0442\u043d\u044b\u0439 \u043e\u0441\u0446\u0438\u043b\u043b\u044f\u0442\u043e\u0440<\/a><br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/228267\/\">\u0427\u0430\u0441\u0442\u044c 13. \u0420\u0435\u0434\u0438\u0437\u0430\u0439\u043d<\/a><br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/231513\/\">\u0427\u0430\u0441\u0442\u044c 14. \u041f\u043e\u043b\u0438\u0444\u043e\u043d\u0438\u044f 1<\/a>  <\/p>\n<hr\/>\n<p>  \u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043f\u043e\u043b\u0438\u0444\u043e\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0441\u0438\u043d\u0442\u0435\u0437\u0430\u0442\u043e\u0440\u0430 \u0438\u0437 \u0442\u0435\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443 \u043d\u0430\u0441 \u0438\u043c\u0435\u044e\u0442\u0441\u044f!<\/p>\n<p>  \u0412 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437 \u043c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u043d\u0430\u0434 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c, \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u043d\u0430\u0447\u043d\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0443 \u043d\u0430\u0434 \u043b\u0435\u0436\u0430\u0449\u0435\u0439 \u0432 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u043b\u0430\u0433\u0438\u043d\u0430 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Polyphony_and_monophony_in_instruments\">\u043f\u043e\u043b\u0438\u0444\u043e\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u0439<\/a> \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u0430\u0443\u0434\u0438\u043e. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0438\u0433\u0440\u0430\u0442\u044c \u0434\u043e 64-\u0445 \u043d\u043e\u0442 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e. \u042d\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043e\u0441\u043d\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u043f\u043b\u0430\u0433\u0438\u043d\u0430, \u043d\u043e \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0443\u0436\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u043d\u0430\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u044b <code>Oscillator<\/code>, <code>EnvelopeGenerator<\/code>, <code>MIDIReceiver<\/code> \u0438 <code>Filter<\/code>.<\/p>\n<p>  \u0412 \u044d\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u043c\u044b \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043a\u043b\u0430\u0441\u0441 <code>Voice<\/code> (\u0433\u043e\u043b\u043e\u0441), \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u043e\u0434\u043d\u0443 \u0437\u0432\u0443\u0447\u0430\u0449\u0443\u044e \u043d\u043e\u0442\u0443. \u0417\u0430\u0442\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043b\u0430\u0441\u0441 <code>VoiceManager<\/code>, \u0441\u043b\u0435\u0434\u044f\u0449\u0438\u0439 \u0437\u0430 \u0442\u0435\u043c, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0435 \u043d\u043e\u0442\u044b \u0437\u0432\u0443\u0447\u0430\u043b\u0438 \u0438 \u0437\u0430\u0433\u043b\u0443\u0448\u0430\u043b\u0438\u0441\u044c \u0432\u043e\u0432\u0440\u0435\u043c\u044f.<br \/>  \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043f\u043e\u0441\u0442\u0435 \u043c\u044b \u043f\u043e\u0447\u0438\u0441\u0442\u0438\u043c \u043a\u043e\u0434 \u043e\u0442 \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0445 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u0445 \u0447\u0430\u0441\u0442\u0435\u0439, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043c\u043e\u0434\u0443\u043b\u044f\u0446\u0438\u044e \u0442\u043e\u043d\u0430 \u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0432 \u0440\u0430\u0431\u043e\u0447\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435. \u041d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u043e\u043b\u043d\u043e. \u041d\u043e \u0432\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0443 \u043d\u0430\u0441 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u0441\u0435 \u043d\u0443\u0436\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b, \u0430 \u0432\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u0432 \u043a\u043e\u043d\u0446\u0435 \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439-\u043f\u043e\u043b\u0438\u0444\u043e\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0439-\u0441\u0443\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0439-\u0431\u043b\u0438\u043d-\u0441\u0438\u043d\u0442\u0435\u0437\u0430\u0442\u043e\u0440!<\/p>\n<p>  <a name=\"habracut\"><\/a><\/p>\n<h3>\u0427\u0442\u043e \u043a\u0443\u0434\u0430?<\/h3>\n<p>  \u0417\u0430\u0434\u0443\u043c\u0430\u0435\u043c\u0441\u044f \u043d\u0430 \u043c\u0438\u043d\u0443\u0442\u043a\u0443 \u043d\u0430\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a\u0438\u0435 \u0447\u0430\u0441\u0442\u0438 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b \u043f\u043b\u0430\u0433\u0438\u043d\u0430 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b, \u0430 \u043a\u0430\u043a\u0438\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u043e\u0431\u043e\u0441\u043e\u0431\u043b\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u043d\u043e\u0442\u044b. \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435, \u0432\u043e\u0442 \u0432\u044b \u0438\u0433\u0440\u0430\u0435\u0442\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043d\u043e\u0442 \u043d\u0430 \u043a\u043b\u0430\u0432\u0438\u0448\u0430\u0445. \u041f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043d\u0430 \u043a\u043b\u0430\u0432\u0438\u0448\u0443 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0430\u0442\u0443\u0445\u0430\u0435\u0442 \u0438, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0442\u0435\u043c\u0431\u0440 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u043c \u043f\u043e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u0433\u0438\u0431\u0430\u044e\u0449\u0435\u0439. \u041a\u043e\u0433\u0434\u0430 \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u0442\u0435 \u0432\u0442\u043e\u0440\u0443\u044e \u043a\u043b\u0430\u0432\u0438\u0448\u0443, \u043f\u0435\u0440\u0432\u0430\u044f \u0432\u0441\u0435 \u0435\u0449\u0435 \u0437\u0432\u0443\u0447\u0438\u0442, \u0438 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0442\u043e\u0440\u043e\u0439 \u0442\u043e\u043d \u0441\u043e \u0441\u0432\u043e\u0438\u043c\u0438 \u043e\u0433\u0438\u0431\u0430\u044e\u0449\u0438\u043c\u0438 \u0430\u043c\u043f\u043b\u0438\u0442\u0443\u0434\u044b \u0438 \u0444\u0438\u043b\u044c\u0442\u0440\u0430. \u0412\u0442\u043e\u0440\u043e\u0435 \u043d\u0430\u0436\u0430\u0442\u0438\u0435 \u043d\u0438\u043a\u0430\u043a \u043d\u0435 \u0432\u043b\u0438\u044f\u0435\u0442 \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0442\u043e\u043d, \u043e\u043d \u0437\u0432\u0443\u0447\u0438\u0442 \u0438 \u043c\u0435\u043d\u044f\u0435\u0442\u0441\u044f <i>\u0441\u0430\u043c \u043f\u043e \u0441\u0435\u0431\u0435<\/i>. \u0422\u0430\u043a \u0447\u0442\u043e \u043a\u0430\u0436\u0434\u044b\u0439 \u0433\u043e\u043b\u043e\u0441 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c \u0438 \u0438\u043c\u0435\u0435\u0442 \u0441\u0432\u043e\u0438 \u043e\u0433\u0438\u0431\u0430\u044e\u0449\u0438\u0435 \u0430\u043c\u043f\u043b\u0438\u0442\u0443\u0434\u044b \u0438 \u0444\u0438\u043b\u044c\u0442\u0440\u0430.<br \/>  LFO \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u043c \u0438 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c, \u043e\u043d \u043f\u0440\u043e\u0441\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438 \u043d\u0435 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043d\u0430\u0436\u0430\u0442\u0438\u0438 \u043d\u0430 \u043a\u043b\u0430\u0432\u0438\u0448\u0438.<br \/>  \u0427\u0442\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u0444\u0438\u043b\u044c\u0442\u0440\u0430, \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u0441\u0440\u0435\u0437\u0430 \u0438 \u0440\u0435\u0437\u043e\u043d\u0430\u043d\u0441 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0432\u0441\u0435 \u0433\u043e\u043b\u043e\u0441\u0430 \u0441\u043c\u043e\u0442\u0440\u044f\u0442 \u043d\u0430 \u043e\u0434\u043d\u0438 \u0438 \u0442\u0435 \u0436\u0435 \u0440\u0443\u0447\u043a\u0438 \u0441\u0440\u0435\u0437\u0430 \u0438 \u0440\u0435\u0437\u043e\u043d\u0430\u043d\u0441\u0430 \u0432 GUI. \u041d\u043e \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u0441\u0440\u0435\u0437\u0430 \u0444\u0438\u043b\u044c\u0442\u0440\u0430 \u043c\u043e\u0434\u0443\u043b\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u043e\u0433\u0438\u0431\u0430\u044e\u0449\u0435\u0439, \u0442\u0430\u043a \u0447\u0442\u043e \u0432 \u043a\u0430\u0436\u0434\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u0430\u044f \u0447\u0430\u0441\u0442\u043e\u0442\u0430 \u0441\u0440\u0435\u0437\u0430 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0433\u043e\u043b\u043e\u0441\u0430 \u0440\u0430\u0437\u043d\u0430\u044f. \u0412\u0437\u0433\u043b\u044f\u043d\u0438\u0442\u0435 \u043d\u0430 <code>Filter::cutoff<\/code> \u2014 \u0432 \u043d\u0435\u0439 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <code>getCalculatedCutoff<\/code>. \u0422\u0430\u043a \u0447\u0442\u043e \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0433\u043e\u043b\u043e\u0441\u0430 \u043d\u0443\u0436\u0435\u043d \u0441\u0432\u043e\u0439 \u0444\u0438\u043b\u044c\u0442\u0440.<br \/>  \u041c\u043e\u0436\u0435\u043c \u043b\u0438 \u043c\u044b \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0434\u0432\u0443\u043c\u044f \u043e\u0441\u0446\u0438\u043b\u043b\u044f\u0442\u043e\u0440\u0430\u043c\u0438 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0433\u043e\u043b\u043e\u0441\u043e\u0432? \u041a\u0430\u0436\u0434\u044b\u0439 <code>Voice<\/code> \u0438\u0433\u0440\u0430\u0435\u0442 \u0441\u0432\u043e\u044e \u043d\u043e\u0442\u0443, \u0442.\u0435. \u0443 \u043d\u0435\u0433\u043e \u0441\u0432\u043e\u044f \u0447\u0430\u0441\u0442\u043e\u0442\u0430, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442, \u0438 \u0441\u0432\u043e\u0439 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u044b\u0439 <code>Oscillator<\/code>.<\/p>\n<p>  \u0412\u043a\u0440\u0430\u0442\u0446\u0435, \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0442\u0430\u043a\u0430\u044f:<\/p>\n<ul>\n<li>\u0412 \u043f\u043b\u0430\u0433\u0438\u043d\u0435 \u0435\u0441\u0442\u044c \u043e\u0434\u0438\u043d <code>MIDIReceiver<\/code> \u0438 \u043e\u0434\u0438\u043d <code>VoiceManager<\/code><\/li>\n<li>\u0423 <code>VoiceManager<\/code> \u0435\u0441\u0442\u044c \u043e\u0434\u0438\u043d <code>LFO<\/code> \u0438 \u043c\u043d\u043e\u0433\u043e \u0433\u043e\u043b\u043e\u0441\u043e\u0432 <code>Voice<\/code><\/li>\n<li>\u0423 <code>Voice<\/code> \u0435\u0441\u0442\u044c \u0434\u0432\u0430 <code>Oscillator<\/code>, \u0434\u0432\u0430 \u0433\u0435\u0440\u0435\u043d\u0430\u0442\u043e\u0440\u0430 \u043e\u0433\u0438\u0431\u0430\u044e\u0449\u0438\u0445 <code>EnvelopeGenerators<\/code> (\u0434\u043b\u044f \u0430\u043c\u043f\u043b\u0438\u0442\u0443\u0434\u044b \u0438 \u0444\u0438\u043b\u044c\u0442\u0440\u0430) \u0438 \u043e\u0434\u0438\u043d <code>Filter<\/code><\/li>\n<\/ul>\n<h3>\u041a\u043b\u0430\u0441\u0441 Voice<\/h3>\n<p>  \u041a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e, \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043d\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441, \u043d\u0430\u0437\u043e\u0432\u0438\u0442\u0435 \u0435\u0433\u043e <code>Voice<\/code>. \u0418, \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e, \u043d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0433\u043e \u0432\u043e \u0432\u0441\u0435 \u0442\u0430\u0440\u0433\u0435\u0442\u044b XCode \u0438 \u0432\u0441\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u044b VS. \u0412 <i>Voice.h<\/i> \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435:<\/p>\n<pre><code class=\"cpp\">#include &quot;Oscillator.h&quot; #include &quot;EnvelopeGenerator.h&quot; #include &quot;Filter.h&quot; <\/code><\/pre>\n<p>  \u0412 \u0442\u0435\u043b\u0435 \u043a\u043b\u0430\u0441\u0441\u0430 \u043d\u0430\u0447\u043d\u0435\u043c \u0441 \u0441\u0435\u043a\u0446\u0438\u0438 <code>private<\/code>:<\/p>\n<pre><code class=\"cpp\">private:     Oscillator mOscillatorOne;     Oscillator mOscillatorTwo;     EnvelopeGenerator mVolumeEnvelope;     EnvelopeGenerator mFilterEnvelope;     Filter mFilter; <\/code><\/pre>\n<p>  \u0417\u0434\u0435\u0441\u044c \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u043e\u0432\u043e\u0433\u043e: \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0433\u043e\u043b\u043e\u0441\u0430 \u0434\u0432\u0430 \u043e\u0441\u0446\u0438\u043b\u043b\u044f\u0442\u043e\u0440\u0430, \u0444\u0438\u043b\u044c\u0442\u0440 \u0438 \u0434\u0432\u0435 \u043e\u0433\u0438\u0431\u0430\u044e\u0449\u0438\u0445.<br \/>  \u041a\u0430\u0436\u0434\u044b\u0439 \u0433\u043e\u043b\u043e\u0441 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 MIDI \u043d\u043e\u0442\u044b \u0438 \u0433\u0440\u043e\u043c\u043a\u043e\u0441\u0442\u0438. \u0414\u043e\u043f\u0438\u0448\u0438\u0442\u0435 \u0442\u0443\u0434\u0430 \u0436\u0435:<\/p>\n<pre><code class=\"cpp\">    int mNoteNumber;     int mVelocity; <\/code><\/pre>\n<p>  \u041a\u0430\u0436\u0434\u0430\u044f \u0438\u0437 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0435\u0442 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0443 \u043c\u043e\u0434\u0443\u043b\u044f\u0446\u0438\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432:<\/p>\n<pre><code class=\"cpp\">    double mFilterEnvelopeAmount;     double mOscillatorMix;     double mFilterLFOAmount;     double mOscillatorOnePitchAmount;     double mOscillatorTwoPitchAmount;     double mLFOValue; <\/code><\/pre>\n<p>  \u0412\u0441\u0435 \u043e\u043d\u0438, \u043a\u0440\u043e\u043c\u0435 <code>mLFOValue<\/code>, \u0441\u0432\u044f\u0437\u0430\u043d\u044b \u0441\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0440\u0443\u0447\u0435\u043a \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430. \u041d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u044d\u0442\u0438 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u044b \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0433\u043e\u043b\u043e\u0441\u043e\u0432, \u043d\u043e \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0434\u0435\u043b\u0430\u0442\u044c \u0438\u0445 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0438 \u0437\u0430\u043a\u0438\u0434\u044b\u0432\u0430\u0442\u044c \u0432 \u043a\u043b\u0430\u0441\u0441 \u043f\u043b\u0430\u0433\u0438\u043d\u0430. \u041a\u0430\u0436\u0434\u043e\u043c\u0443 \u0433\u043e\u043b\u043e\u0441\u0443 \u043d\u0443\u0436\u0435\u043d \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u044d\u0442\u0438\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u0435\u043c\u043f\u043b, \u0430 \u043a\u043b\u0430\u0441\u0441 Voice \u0434\u0430\u0436\u0435 \u043d\u0435 \u0437\u043d\u0430\u0435\u0442 \u043e \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 \u043f\u043b\u0430\u0433\u0438\u043d\u0430 (\u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 <code>#include &quot;SpaceBass.h&quot;<\/code>). \u041d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u0434\u043e\u0441\u0442\u0443\u043f \u0431\u044b\u043b\u043e \u0431\u044b \u0442\u0440\u0443\u0434\u043e\u0435\u043c\u043a\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439.<br \/>  \u0418 \u0435\u0441\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440. \u0412\u044b \u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u043c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u0444\u043b\u0430\u0433 <code>isMuted<\/code> \u0432 \u043a\u043b\u0430\u0441\u0441 <code>Oscillator<\/code>? \u041f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u043c \u0435\u0433\u043e \u0432 <code>Voice<\/code>, \u0447\u0442\u043e\u0431\u044b \u043a\u043e\u0433\u0434\u0430 \u0433\u043e\u043b\u043e\u0441 \u043c\u043e\u043b\u0447\u0438\u0442, \u043d\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u043b\u0438\u0441\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043e\u0441\u0446\u0438\u043b\u043b\u044f\u0442\u043e\u0440\u0430, \u043e\u0433\u0438\u0431\u0430\u044e\u0449\u0438\u0445 \u0438 \u0444\u0438\u043b\u044c\u0442\u0440\u0430:<\/p>\n<pre><code class=\"cpp\">    bool isActive; <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c <i>\u043f\u0435\u0440\u0435\u0434<\/i> <code>private<\/code> \u0434\u043e\u0431\u0430\u0432\u0438\u043c <code>public<\/code>. \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430:<\/p>\n<pre><code class=\"cpp\">public:     Voice()     : mNoteNumber(-1),     mVelocity(0),     mFilterEnvelopeAmount(0.0),     mFilterLFOAmount(0.0),     mOscillatorOnePitchAmount(0.0),     mOscillatorTwoPitchAmount(0.0),     mOscillatorMix(0.5),     mLFOValue(0.0),     isActive(false) {         \/\/ Set myself free everytime my volume envelope has fully faded out of RELEASE stage:         mVolumeEnvelope.finishedEnvelopeCycle.Connect(this, &Voice::setFree);     }; <\/code><\/pre>\n<p>  \u042d\u0442\u0438 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u044e\u0442 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0441 \u0440\u0430\u0437\u0443\u043c\u043d\u044b\u043c\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u043c\u0438. \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e <code>Voice<\/code> \u043d\u0435 \u0430\u043a\u0442\u0438\u0432\u0435\u043d. \u0422\u0430\u043a\u0436\u0435, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u0441\u0438\u0433\u043d\u0430\u043b\u044b \u0438 \u0441\u043b\u043e\u0442\u044b <code>EnvelopeGenerator<\/code>, \u043c\u044b \u00ab\u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0435\u043c\u00bb \u0433\u043e\u043b\u043e\u0441 \u043a\u0430\u043a \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0433\u0438\u0431\u0430\u044e\u0449\u0430\u044f \u0430\u043c\u043f\u043b\u0438\u0442\u0443\u0434\u044b \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0438\u0437 \u0441\u0442\u0430\u0434\u0438\u0438 release.<br \/>  \u0414\u043e\u0431\u0430\u0432\u0438\u043c \u0441\u0435\u0442\u0442\u0435\u0440\u044b \u0432 <code>public<\/code>:<\/p>\n<pre><code class=\"cpp\"> inline void setFilterEnvelopeAmount(double amount) { mFilterEnvelopeAmount = amount; }     inline void setFilterLFOAmount(double amount) { mFilterLFOAmount = amount; }     inline void setOscillatorOnePitchAmount(double amount) { mOscillatorOnePitchAmount = amount; }     inline void setOscillatorTwoPitchAmount(double amount) { mOscillatorTwoPitchAmount = amount; }     inline void setOscillatorMix(double mix) { mOscillatorMix = mix; }     inline void setLFOValue(double value) { mLFOValue = value; }      inline void setNoteNumber(int noteNumber) {         mNoteNumber = noteNumber;         double frequency = 440.0 * pow(2.0, (mNoteNumber - 69.0) \/ 12.0);         mOscillatorOne.setFrequency(frequency);         mOscillatorTwo.setFrequency(frequency);     } <\/code><\/pre>\n<p>  \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0437\u0434\u0435\u0441\u044c \u2014 \u044d\u0442\u043e <code>setNoteNumber<\/code>. \u041e\u043d\u0430 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442 \u0447\u0430\u0441\u0442\u043e\u0442\u0443 \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0439 \u043d\u043e\u0442\u044b \u043f\u043e \u0443\u0436\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e\u0439 \u043d\u0430\u043c \u0444\u043e\u0440\u043c\u0443\u043b\u0435 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442 \u0435\u0435 \u043e\u0431\u043e\u0438\u043c \u043e\u0441\u0446\u0438\u043b\u043b\u044f\u0442\u043e\u0440\u0430\u043c. \u041f\u043e\u0441\u043b\u0435 \u043d\u0435\u0435 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435:<\/p>\n<pre><code class=\"cpp\">    double nextSample();     void setFree(); <\/code><\/pre>\n<p>  \u041a\u0430\u043a <code>Oscillator::nextSample<\/code> \u0434\u0430\u0435\u0442 \u043d\u0430\u043c \u0432\u044b\u0445\u043e\u0434 <code>Oscillator<\/code>, \u0442\u0430\u043a \u0438 <code>Voice::nextSample<\/code> \u0432\u044b\u0434\u0430\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0438\u0440\u0443\u044e\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0433\u043e\u043b\u043e\u0441\u0430 \u043f\u043e\u0441\u043b\u0435 \u043e\u0433\u0438\u0431\u0430\u044e\u0449\u0435\u0439 \u0430\u043c\u043f\u043b\u0438\u0442\u0443\u0434\u044b \u0438 \u0444\u0438\u043b\u044c\u0442\u0440\u0430. \u041d\u0430\u043f\u0438\u0448\u0435\u043c \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u0432 <i>Voice.cpp<\/i>:<\/p>\n<pre><code class=\"cpp\">double Voice::nextSample() {     if (!isActive) return 0.0;      double oscillatorOneOutput = mOscillatorOne.nextSample();     double oscillatorTwoOutput = mOscillatorTwo.nextSample();     double oscillatorSum = ((1 - mOscillatorMix) * oscillatorOneOutput) + (mOscillatorMix * oscillatorTwoOutput);      double volumeEnvelopeValue = mVolumeEnvelope.nextSample();     double filterEnvelopeValue = mFilterEnvelope.nextSample();      mFilter.setCutoffMod(filterEnvelopeValue * mFilterEnvelopeAmount + mLFOValue * mFilterLFOAmount);      return mFilter.process(oscillatorSum * volumeEnvelopeValue * mVelocity \/ 127.0); } <\/code><\/pre>\n<p>  \u041f\u0435\u0440\u0432\u0430\u044f \u0441\u0442\u043e\u0447\u043a\u0430 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442, \u0447\u0442\u043e \u043a\u043e\u0433\u0434\u0430 \u0433\u043e\u043b\u043e\u0441 \u043d\u0435\u0430\u043a\u0442\u0438\u0432\u0435\u043d \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043d\u043e\u043b\u044c. \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0442\u0440\u0438 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u044e\u0442 <code>nextSample<\/code> \u0434\u043b\u044f \u043e\u0431\u043e\u0438\u0445 \u043e\u0441\u0446\u0438\u043b\u043b\u044f\u0442\u043e\u0440\u043e\u0432 \u0438 \u0441\u043c\u0435\u0448\u0438\u0432\u0430\u044e\u0442 \u0438\u0445 \u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0438\u0438 \u0441 <code>mOscillatorMix<\/code>. \u041a\u043e\u0433\u0434\u0430 <code>mOscillatorMix<\/code> \u0440\u0430\u0432\u0435\u043d \u043d\u0443\u043b\u044e, \u0441\u043b\u044b\u0448\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e <code>oscillatorOneOutput<\/code>. \u041f\u0440\u0438 <code>0.5<\/code> \u043e\u0431\u0430 \u043e\u0441\u0446\u0438\u043b\u043b\u044f\u0442\u043e\u0440\u0430 \u0438\u043c\u0435\u044e\u0442 \u0440\u0430\u0432\u043d\u0443\u044e \u0430\u043c\u043f\u043b\u0438\u0442\u0443\u0434\u0443.<br \/>  \u0417\u0430\u0442\u0435\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0441\u0435\u043c\u043f\u043b \u043e\u0431\u0435\u0438\u0445 \u043e\u0433\u0438\u0431\u0430\u044e\u0449\u0438\u0445. \u041c\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c <code>filterEnvelopeValue<\/code> \u043a \u0447\u0430\u0441\u0442\u043e\u0442\u0435 \u0441\u0440\u0435\u0437\u0430 \u0444\u0438\u043b\u044c\u0442\u0440\u0430 \u0438 \u0431\u0435\u0440\u0435\u043c \u0432 \u0440\u0430\u0441\u0447\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 LFO. \u041e\u0431\u0449\u0430\u044f \u043c\u043e\u0434\u0443\u043b\u044f\u0446\u0438\u044f \u0441\u0440\u0435\u0437\u0430 \u044d\u0442\u043e \u0441\u0443\u043c\u043c\u0430 \u043e\u0433\u0438\u0431\u0430\u044e\u0449\u0435\u0439 \u0444\u0438\u043b\u044c\u0442\u0440\u0430 \u0438 LFO.<br \/>  \u041c\u043e\u0434\u0443\u043b\u044f\u0446\u0438\u044f \u0442\u043e\u043d\u0430 \u043e\u0431\u043e\u0438\u0445 \u043e\u0441\u0446\u0438\u043b\u043b\u044f\u0442\u043e\u0440\u043e\u0432 \u044d\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u044b\u0445\u043e\u0434 LFO \u043f\u043e\u043c\u043d\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u043d\u0430 \u0432\u0435\u043b\u0438\u0447\u0438\u043d\u0443 \u043c\u043e\u0434\u0443\u043b\u044f\u0446\u0438\u0438. \u041c\u044b \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u044d\u0442\u043e \u0447\u0435\u0440\u0435\u0437 \u043c\u0438\u043d\u0443\u0442\u043a\u0443.<br \/>  \u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u0441\u0442\u0440\u043e\u043a\u0430. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435 \u0441\u043a\u043e\u0431\u043e\u043a: \u0431\u0435\u0440\u0435\u043c \u0441\u0443\u043c\u043c\u0443 \u0434\u0432\u0443\u0445 \u043e\u0441\u0446\u0438\u043b\u043b\u044f\u0442\u043e\u0440\u043e\u0432, \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c \u043e\u0433\u0438\u0431\u0430\u044e\u0449\u0443\u044e \u0433\u0440\u043e\u043c\u043a\u043e\u0441\u0442\u0438 \u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0433\u0440\u043e\u043c\u043a\u043e\u0441\u0442\u0438 \u043d\u043e\u0442\u044b. \u0417\u0430\u0442\u0435\u043c \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0447\u0435\u0440\u0435\u0437 <code>mFilter.process<\/code>, \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0442\u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0432\u044b\u0445\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c.<\/p>\n<p>  \u0418\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f <code>setFree<\/code> \u043f\u0440\u0435\u0434\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u0430\u044f:<\/p>\n<pre><code class=\"cpp\">void Voice::setFree() {     isActive = false; } <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0443\u0436\u0435 \u0433\u043e\u0432\u043e\u0440\u0438\u043b\u043e\u0441\u044c, \u0432\u044b\u0437\u043e\u0432 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 <code>mVolumeEnvelope<\/code> \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0437\u0430\u0442\u0443\u0445\u0430\u0435\u0442.<\/p>\n<h3>VoiceManager<\/h3>\n<p>  \u041f\u043e\u0440\u0430 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0433\u043e\u043b\u043e\u0441\u0430\u043c\u0438. \u0421\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u043a\u043b\u0430\u0441\u0441 \u0441 \u0438\u043c\u0435\u043d\u0435\u043c <code>VoiceManager<\/code>. \u0412 \u0445\u0435\u0434\u0435\u0440\u0435 \u043d\u0430\u0447\u043d\u0438\u0442\u0435 \u0441 \u044d\u0442\u0438\u0445 \u0441\u0442\u0440\u043e\u043a:<\/p>\n<pre><code class=\"cpp\">#include &quot;Voice.h&quot;  class VoiceManager { }; <\/code><\/pre>\n<p>  \u0418 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u0435 <code>private<\/code> \u0447\u043b\u0435\u043d\u0430\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0430:<\/p>\n<pre><code class=\"cpp\">static const int NumberOfVoices = 64; Voice voices[NumberOfVoices]; Oscillator mLFO; Voice* findFreeVoice(); <\/code><\/pre>\n<p>  \u041a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u0430 <code>NumberOfVoices<\/code> \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0437\u0432\u0443\u0447\u0430\u0449\u0438\u0445 \u0433\u043e\u043b\u043e\u0441\u043e\u0432. \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043c\u0430\u0441\u0441\u0438\u0432 \u0438\u0437 \u0433\u043e\u043b\u043e\u0441\u043e\u0432. \u042d\u0442\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043c\u0435\u0441\u0442\u043e \u043f\u043e\u0434 64 \u0433\u043e\u043b\u043e\u0441\u0430, \u0442\u0430\u043a \u0447\u0442\u043e \u043b\u0443\u0447\u0448\u0435 \u0437\u0430\u0434\u0443\u043c\u0430\u0442\u044c\u0441\u044f \u043e <a href=\"http:\/\/www.cplusplus.com\/doc\/tutorial\/dynamic\/\">\u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u043c \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u043f\u0430\u043c\u044f\u0442\u0438<\/a>. \u0412\u043f\u0440\u043e\u0447\u0435\u043c, \u043a\u043b\u0430\u0441\u0441 \u043f\u043b\u0430\u0433\u0438\u043d\u0430 \u0438 \u0442\u0430\u043a \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d \u0434\u0438\u043d\u0430\u043c\u0438\u0447\u0435\u0441\u043a\u0438 (\u043f\u043e\u0438\u0449\u0438\u0442\u0435 &quot;<code>new PLUG_CLASS_NAME<\/code>&quot; \u0432 <i>Iplug_include_in_plug_src.h<\/i>), \u0442\u0430\u043a \u0447\u0442\u043e \u0432\u0441\u0435 \u0447\u043b\u0435\u043d\u044b \u043a\u043b\u0430\u0441\u0441\u0430 \u043f\u043b\u0430\u0433\u0438\u043d\u0430 \u0442\u043e\u0436\u0435 \u0432 <a href=\"http:\/\/ru.wikipedia.org\/wiki\/%D0%9A%D1%83%D1%87%D0%B0_%28%D0%BF%D0%B0%D0%BC%D1%8F%D1%82%D1%8C%29\">\u043a\u0443\u0447\u0435<\/a>.<\/p>\n<p>  <code>mLFO<\/code> \u2014 \u044d\u0442\u043e \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u0439 LFO \u0434\u043b\u044f \u043f\u043b\u0430\u0433\u0438\u043d\u0430. \u041e\u043d \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u043f\u0435\u0440\u0435\u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f, \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0441\u0446\u0438\u043b\u043b\u0438\u0440\u0443\u0435\u0442. \u041c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043f\u043e\u0440\u0438\u0442\u044c, \u0447\u0442\u043e \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 \u043f\u043b\u0430\u0433\u0438\u043d\u0430 (<code>VoiceManager<\/code> \u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u043e\u0431 LFO). \u041d\u043e \u044d\u0442\u043e \u0432\u043d\u0435\u0441\u0435\u0442 \u0435\u0449\u0435 \u043e\u0434\u0438\u043d \u0441\u043b\u043e\u0439 \u0440\u0430\u0437\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f \u043c\u0435\u0436\u0434\u0443 \u0433\u043e\u043b\u043e\u0441\u0430\u043c\u0438 <code>Voice<\/code> \u0438 LFO, \u0430 \u0437\u043d\u0430\u0447\u0438\u0442, \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435 <a href=\"http:\/\/ru.wikipedia.org\/wiki\/Glue_code\">\u0441\u043a\u043b\u0435\u0438\u0432\u0430\u044e\u0449\u0435\u0433\u043e \u043a\u043e\u0434\u0430<\/a>.<br \/>  <code>findFreeVoice<\/code> \u044d\u0442\u043e \u0432\u0441\u043f\u043e\u043c\u043e\u0433\u0430\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u0433\u043e\u043b\u043e\u0441\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435 \u0437\u0432\u0443\u0447\u0430\u0442 \u0432 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442. \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0435\u0435 \u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044e \u0432 <i>VoiceManager.cpp<\/i>:<\/p>\n<pre><code class=\"cpp\">Voice* VoiceManager::findFreeVoice() {     Voice* freeVoice = NULL;     for (int i = 0; i &lt; NumberOfVoices; i++) {         if (!voices[i].isActive) {             freeVoice = &(voices[i]);             break;         }     }     return freeVoice; } <\/code><\/pre>\n<p>  \u041e\u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0438\u0442\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u043d\u0430\u0434 \u0432\u0441\u0435\u043c\u0438 \u0433\u043e\u043b\u043e\u0441\u0430\u043c\u0438 \u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442 \u043f\u0435\u0440\u0432\u044b\u0439 \u043c\u043e\u043b\u0447\u0430\u0449\u0438\u0439. \u041c\u044b \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c (\u0432\u043c\u0435\u0441\u0442\u043e \u0441\u0441\u044b\u043b\u043a\u0438 <code>&<\/code>), \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0441\u0441\u044b\u043b\u043a\u0438, \u043c\u043e\u0436\u043d\u043e \u0432\u0435\u0440\u043d\u0443\u0442\u044c <code>NULL<\/code>. \u042d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u0437\u043d\u0430\u0447\u0430\u0442\u044c, \u0447\u0442\u043e \u0432\u0441\u0435 \u0433\u043e\u043b\u043e\u0441\u0430 \u0437\u0432\u0443\u0447\u0430\u0442.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u0432 <code>public<\/code> \u0442\u0430\u043a\u0438\u0435 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439:<\/p>\n<pre><code class=\"cpp\">void onNoteOn(int noteNumber, int velocity); void onNoteOff(int noteNumber, int velocity); double nextSample(); <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u0438\u0437 \u0438\u043c\u0435\u043d\u0438, <code>onNoteOn<\/code> \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0438 MIDI \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f Note On. <code>onNoteOff<\/code>, \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 Note Off \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0438. \u041d\u0430\u043f\u0438\u0448\u0435\u043c \u043a\u043e\u0434 \u044d\u0442\u0438\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432 .cpp \u0444\u0430\u0439\u043b\u0435 \u043a\u043b\u0430\u0441\u0441\u0430:<\/p>\n<pre><code class=\"cpp\">void VoiceManager::onNoteOn(int noteNumber, int velocity) {     Voice* voice = findFreeVoice();     if (!voice) {         return;     }     voice-&gt;reset();     voice-&gt;setNoteNumber(noteNumber);     voice-&gt;mVelocity = velocity;     voice-&gt;isActive = true;     voice-&gt;mVolumeEnvelope.enterStage(EnvelopeGenerator::ENVELOPE_STAGE_ATTACK);     voice-&gt;mFilterEnvelope.enterStage(EnvelopeGenerator::ENVELOPE_STAGE_ATTACK); } <\/code><\/pre>\n<p>  \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0439 \u0433\u043e\u043b\u043e\u0441 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 <code>findFreeVoice<\/code>. \u0415\u0441\u043b\u0438 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043d\u0430\u0448\u043b\u043e\u0441\u044c, \u043c\u044b \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043a\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u0433\u043e\u043b\u043e\u0441\u0430 \u0437\u0432\u0443\u0447\u0430\u0442, \u043d\u0430\u0436\u0430\u0442\u0438\u0435 \u0435\u0449\u0435 \u043e\u0434\u043d\u043e\u0439 \u043a\u043b\u0430\u0432\u0438\u0448\u0438 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u043d\u0438\u043a\u0430\u043a\u043e\u0433\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430. \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u0434\u0445\u043e\u0434\u0430 <a href=\"http:\/\/electronicmusic.wikia.com\/wiki\/Voice_stealing\">voice stealing<\/a> \u0431\u0443\u0434\u0435\u0442 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u0442\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u043f\u043e\u0441\u0442\u0430. \u0415\u0441\u043b\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0439 \u0433\u043e\u043b\u043e\u0441, \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0435\u0433\u043e \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0434\u043e \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f (<code>reset<\/code>, \u043c\u044b \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u044d\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0441\u043a\u043e\u0440\u043e). \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u0437\u0430\u0434\u0430\u0435\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <code>setNoteNumber<\/code> \u0438 <code>mVelocity<\/code>. \u041f\u043e\u043c\u0435\u0447\u0430\u0435\u043c \u0433\u043e\u043b\u043e\u0441 \u043a\u0430\u043a \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0439 \u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u043c \u043e\u0431\u0435 \u043e\u0433\u0438\u0431\u0430\u044e\u0449\u0438\u0435 \u0432 \u0441\u0442\u0430\u0434\u0438\u044e attack.<br \/>  \u0415\u0441\u043b\u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0441\u0431\u043e\u0440\u043a\u0443 \u043f\u0440\u044f\u043c\u043e \u0441\u0435\u0439\u0447\u0430\u0441, \u0432\u044b\u0441\u043a\u043e\u0447\u0438\u0442 \u043e\u0448\u0438\u0431\u043a\u0430 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u044b \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a <code>private<\/code> \u0447\u043b\u0435\u043d\u0430\u043c <code>Voice<\/code> \u0438\u0437\u0432\u043d\u0435. \u041d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u043b\u0443\u0447\u0448\u0438\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0432 \u044d\u0442\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0435 \u0441\u043b\u043e\u0432\u043e <a href=\"http:\/\/en.wikipedia.org\/wiki\/Friend_class\">friend<\/a>. \u0414\u043e\u0431\u0430\u0432\u044c\u0442\u0435 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0443\u044e \u0441\u0442\u0440\u043e\u0447\u043a\u0443 \u043f\u0435\u0440\u0435\u0434 <code>public<\/code> \u0432 <i>Voice.h<\/i>: <\/p>\n<pre><code class=\"cpp\">friend class VoiceManager; <\/code><\/pre>\n<p>  \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u0447\u043a\u0435 <code>Voice<\/code> \u0434\u0430\u0435\u0442 <code>VoiceManager<\/code> \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u0432\u043e\u0438\u043c <code>private<\/code> \u0447\u043b\u0435\u043d\u0430\u043c. \u042f \u043d\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u043a \u043e\u0431\u0448\u0438\u0440\u043d\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430, \u043d\u043e \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u043a\u043b\u0430\u0441\u0441 <code>Foo<\/code> \u0438 \u043a\u043b\u0430\u0441\u0441 <code>FooManager<\/code>, \u044d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0441\u0435\u0442\u0442\u0435\u0440\u043e\u0432.<\/p>\n<p>  <code>onNoteOff<\/code> \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cpp\">void VoiceManager::onNoteOff(int noteNumber, int velocity) {     \/\/ Find the voice(s) with the given noteNumber:     for (int i = 0; i &lt; NumberOfVoices; i++) {         Voice& voice = voices[i];         if (voice.isActive && voice.mNoteNumber == noteNumber) {             voice.mVolumeEnvelope.enterStage(EnvelopeGenerator::ENVELOPE_STAGE_RELEASE);             voice.mFilterEnvelope.enterStage(EnvelopeGenerator::ENVELOPE_STAGE_RELEASE);         }     } } <\/code><\/pre>\n<p>  \u041c\u044b \u043d\u0430\u0445\u043e\u0434\u0438\u043c \u0432\u0441\u0435 \u0433\u043e\u043b\u043e\u0441\u0430 \u0441 \u043d\u043e\u043c\u0435\u0440\u043e\u043c \u043e\u0442\u043f\u0443\u0449\u0435\u043d\u043d\u043e\u0439 \u043d\u043e\u0442\u044b \u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u043c \u0438\u0445 \u043e\u0433\u0438\u0431\u0430\u044e\u0449\u0438\u0435 \u0432 \u0441\u0442\u0430\u0434\u0438\u044e release. \u041f\u043e\u0447\u0435\u043c\u0443 <i>\u0433\u043e\u043b\u043e\u0441\u0430<\/i>, \u0430 \u043d\u0435 \u0433\u043e\u043b\u043e\u0441? \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435 \u0441\u0435\u0431\u0435, \u0447\u0442\u043e \u0443 \u0432\u0430\u0441 \u043e\u0447\u0435\u043d\u044c \u0434\u043b\u0438\u0442\u0435\u043b\u044c\u043d\u0430\u044f \u0441\u0442\u0430\u0434\u0438\u044f \u0437\u0430\u0442\u0443\u0445\u0430\u043d\u0438\u044f \u0432 \u043e\u0433\u0438\u0431\u0430\u044e\u0449\u0435\u0439 \u0430\u043c\u043f\u043b\u0438\u0442\u0443\u0434\u044b. \u0412\u044b \u043d\u0430\u0436\u0438\u043c\u0430\u0435\u0442\u0435 \u043d\u0430 \u043a\u043b\u0430\u0432\u0438\u0448\u0443 \u0438 \u043e\u0442\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0435 \u0435\u0435, \u0438, \u043f\u043e\u043a\u0430 \u0445\u0432\u043e\u0441\u0442 \u043d\u043e\u0442\u044b \u0432\u0441\u0435 \u0435\u0449\u0435 \u0437\u0432\u0443\u0447\u0438\u0442, \u0431\u044b\u0441\u0442\u0440\u043e \u0436\u043c\u0435\u0442\u0435 \u044d\u0442\u0443 \u043a\u043b\u0430\u0432\u0438\u0448\u0443 \u0435\u0449\u0435 \u0440\u0430\u0437. \u0415\u0441\u0442\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0432\u044b \u043d\u0435 \u0445\u043e\u0442\u0438\u0442\u0435 \u043e\u0431\u0440\u0443\u0431\u0438\u0442\u044c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0443\u044e \u0437\u0432\u0443\u0447\u0430\u0449\u0443\u044e \u043d\u043e\u0442\u0443. \u042d\u0442\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043e\u0447\u0435\u043d\u044c \u043d\u0435\u043a\u0440\u0430\u0441\u0438\u0432\u043e. \u041d\u0443\u0436\u043d\u043e \u0438 \u0447\u0442\u043e\u0431\u044b \u0434\u043e\u0437\u0432\u0443\u0447\u0430\u043b\u0430 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0430\u044f \u043d\u043e\u0442\u0430, \u0438 \u0447\u0442\u043e\u0431\u044b \u043d\u043e\u0432\u0430\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u0437\u0432\u0443\u0447\u0430\u0442\u044c. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0432\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u0434\u043d\u043e\u0433\u043e \u0433\u043e\u043b\u043e\u0441\u0430 \u043d\u0430 \u043d\u043e\u0442\u0443. \u0415\u0441\u043b\u0438 \u0434\u043e\u043b\u0431\u0438\u0442\u044c \u043f\u043e \u043a\u043b\u0430\u0432\u0438\u0448\u0430\u043c \u043e\u0447\u0435\u043d\u044c \u0431\u044b\u0441\u0442\u0440\u043e, \u0442\u043e \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043c\u043d\u043e\u0433\u043e \u0433\u043e\u043b\u043e\u0441\u043e\u0432.<br \/>  \u0422\u0430\u043a \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442, \u0435\u0441\u043b\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443 \u043d\u0430\u0441 \u043f\u044f\u0442\u044c \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u0433\u043e\u043b\u043e\u0441\u043e\u0432 \u0434\u043b\u044f \u0414\u043e \u0442\u0440\u0435\u0442\u044c\u0435\u0439 \u043e\u043a\u0442\u0430\u0432\u044b \u0438 \u043c\u044b \u043e\u0442\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u044d\u0442\u0443 \u043a\u043b\u0430\u0432\u0438\u0448\u0443? \u0412\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <code>onNoteOff<\/code> \u0438 \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442 \u043e\u0433\u0438\u0431\u0430\u044e\u0449\u0438\u0435 \u0432\u0441\u0435\u0445 \u043f\u044f\u0442\u0438 \u0433\u043e\u043b\u043e\u0441\u043e\u0432 \u0432 \u0441\u0442\u0430\u0434\u0438\u044e release. \u0427\u0435\u0442\u044b\u0440\u0435 \u0438\u0437 \u043d\u0438\u0445 \u0438 \u0442\u0430\u043a \u0443\u0436\u0435 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0434\u0438\u0438, \u0442\u0430\u043a \u0447\u0442\u043e \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u043f\u0435\u0440\u0432\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 <code>EnvelopeGenerator::enterStage<\/code>:<\/p>\n<pre><code class=\"cpp\">if (currentStage == newStage) return; <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u0434\u043b\u044f \u044d\u0442\u0438\u0445 \u0447\u0435\u0442\u044b\u0440\u0435\u0445 \u043d\u043e\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0435\u0442, \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u0437\u0430\u0433\u0432\u043e\u0437\u0434\u043e\u043a \u0442\u0443\u0442 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442.<\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0447\u043b\u0435\u043d <code>nextSample<\/code> \u0434\u043b\u044f <code>VoiceManager<\/code>. \u041e\u043d\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0445 \u0433\u043e\u043b\u043e\u0441\u043e\u0432:<\/p>\n<pre><code class=\"cpp\">double VoiceManager::nextSample() {     double output = 0.0;     double lfoValue = mLFO.nextSample();     for (int i = 0; i &lt; NumberOfVoices; i++) {         Voice& voice = voices[i];         voice.setLFOValue(lfoValue);         output += voice.nextSample();     }     return output; } <\/code><\/pre>\n<p>  \u041c\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0441 \u0442\u0438\u0448\u0438\u043d\u044b <code>(0.0)<\/code>, \u0438\u0442\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u043d\u0430\u0434 \u0432\u0441\u0435\u043c\u0438 \u0433\u043e\u043b\u043e\u0441\u0430\u043c\u0438, \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0442\u0435\u043a\u0443\u0449\u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 LFO \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432\u044b\u0445\u043e\u0434 \u0433\u043e\u043b\u043e\u0441\u0430 \u043a \u0441\u0443\u043c\u043c\u0430\u0440\u043d\u043e\u043c\u0443 \u0432\u044b\u0445\u043e\u0434\u0443. \u041a\u0430\u043a \u043c\u044b \u043f\u043e\u043c\u043d\u0438\u043c, \u0435\u0441\u043b\u0438 \u0433\u043e\u043b\u043e\u0441 \u043d\u0435\u0430\u043a\u0442\u0438\u0432\u0435\u043d, \u0435\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>Voice::nextSample<\/code> \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0438\u0447\u0435\u0433\u043e \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u0438 \u0441\u0440\u0430\u0437\u0443 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442\u0441\u044f.<\/p>\n<h3>\u041c\u043d\u043e\u0433\u043e\u0440\u0430\u0437\u043e\u0432\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b<\/h3>\n<p>  \u0414\u043e \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430 \u043c\u044b \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u044b <code>Oscillator<\/code> \u0438 <code>Filter<\/code> \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0438\u0445 \u043d\u0430 \u043f\u0440\u043e\u0442\u044f\u0436\u0435\u043d\u0438\u0438 \u0432\u0441\u0435\u0433\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u043b\u0430\u0433\u0438\u043d\u0430. \u041d\u043e VoiceManager \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0435 \u0433\u043e\u043b\u043e\u0441\u0430, \u0442\u0430\u043a \u0447\u0442\u043e \u043d\u0430\u0434\u043e \u043f\u0440\u0438\u0434\u0443\u043c\u0430\u0442\u044c, \u043a\u0430\u043a \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u0435\u0440\u0435\u0432\u0435\u0441\u0442\u0438 \u0433\u043e\u043b\u043e\u0441 \u0432 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435. \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0432 <code>public<\/code> \u0445\u0435\u0434\u0435\u0440\u0430 <code>Voice<\/code>:<\/p>\n<pre><code class=\"cpp\">void reset(); <\/code><\/pre>\n<p>  \u0422\u0435\u043b\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0432 .cpp:<\/p>\n<pre><code class=\"cpp\">void Voice::reset() {     mNoteNumber = -1;     mVelocity = 0;     mOscillatorOne.reset();     mOscillatorTwo.reset();     mVolumeEnvelope.reset();     mFilterEnvelope.reset();     mFilter.reset(); } <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e, \u0437\u0434\u0435\u0441\u044c \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u044e\u0442\u0441\u044f <code>mNoteNumber<\/code> \u0438 <code>mVelocity<\/code>, \u0437\u0430\u0442\u0435\u043c \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043e\u0441\u0446\u0438\u043b\u043b\u044f\u0442\u043e\u0440\u044b, \u043e\u0433\u0438\u0431\u0430\u044e\u0449\u0438\u0435 \u0438 \u0444\u0438\u043b\u044c\u0442\u0440. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u044d\u0442\u043e \u043d\u0430\u043f\u0438\u0448\u0435\u043c!<\/p>\n<p>  \u0412 <code>public<\/code> \u0441\u0435\u043a\u0446\u0438\u0438 <i>Oscillator.h<\/i> \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435:<\/p>\n<pre><code class=\"cpp\">void reset() { mPhase = 0.0; } <\/code><\/pre>\n<p>  \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c \u0444\u043e\u0440\u043c\u0443 \u0432\u043e\u043b\u043d\u044b \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0437\u0432\u0443\u0447\u0430\u0442\u044c \u0433\u043e\u043b\u043e\u0441.<\/p>\n<p>  \u0417\u0430\u043e\u0434\u043d\u043e, \u043f\u043e\u043a\u0430 \u043c\u044b \u0442\u0430\u043c, \u0443\u0434\u0430\u043b\u0438\u0442\u0435 \u0444\u043b\u0430\u0433 <code>isMuted<\/code> \u0438\u0437 \u0441\u0435\u043a\u0446\u0438\u0438 <code>private<\/code>. \u041d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0435\u0433\u043e \u0442\u0430\u043a\u0436\u0435 \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u0438 \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u0447\u043b\u0435\u043d \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>setMuted<\/code>. \u041c\u044b \u0442\u0435\u043f\u0435\u0440\u044c \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u0435\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0430\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u0438 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 <code>Voice<\/code>, \u0442\u0430\u043a \u0447\u0442\u043e \u043e\u0441\u0446\u0438\u043b\u043b\u044f\u0442\u043e\u0440\u0443 \u044d\u0442\u043e \u0432\u0441\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u043e. \u0423\u0434\u0430\u043b\u0438\u0442\u0435 \u044d\u0442\u0443 \u0441\u0442\u0440\u043e\u0447\u043a\u0443 \u0438\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>Oscillator::nextSample<\/code>:<\/p>\n<pre><code class=\"cpp\">\/\/ remove this line: if(isMuted) return value; <\/code><\/pre>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f <code>reset<\/code> \u0432 <code>EnvelopeGenerator<\/code> \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0434\u043b\u0438\u043d\u043d\u0435\u0435. \u0412 \u0441\u0435\u043a\u0446\u0438\u0438 <code>public<\/code> \u0445\u0435\u0434\u0435\u0440\u0430 <code>EnvelopeGenerator<\/code> \u043d\u0430\u043f\u0438\u0448\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435:<\/p>\n<pre><code class=\"cpp\">void reset() {     currentStage = ENVELOPE_STAGE_OFF;     currentLevel = minimumLevel;     multiplier = 1.0;     currentSampleIndex = 0;     nextStageSampleIndex = 0; } <\/code><\/pre>\n<p>  \u0422\u0443\u0442 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u0431\u0440\u043e\u0441\u0438\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u0432\u0441\u0435 \u043b\u0438\u043d\u0435\u0439\u043d\u043e. \u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c <code>reset<\/code> \u0434\u043b\u044f \u043a\u043b\u0430\u0441\u0441\u0430 <code>Filter<\/code> (\u0442\u043e\u0436\u0435 \u0432 <code>public<\/code>):<\/p>\n<pre><code class=\"cpp\">void reset() {     buf0 = buf1 = buf2 = buf3 = 0.0; } <\/code><\/pre>\n<p>  \u041a\u0430\u043a \u0432\u044b \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435 \u043f\u043e\u043c\u043d\u0438\u0442\u0435, \u044d\u0442\u0438 \u0431\u0443\u0444\u0435\u0440\u044b \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0432 \u0441\u0435\u0431\u0435 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0435 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0441\u0435\u043c\u043f\u043b\u044b \u0444\u0438\u043b\u044c\u0442\u0440\u0430. \u041a\u043e\u0433\u0434\u0430 \u043c\u044b \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0433\u043e\u043b\u043e\u0441, \u044d\u0442\u0438 \u0431\u0443\u0444\u0435\u0440\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043f\u0443\u0441\u0442\u044b\u043c\u0438.<\/p>\n<p>  \u041f\u043e\u0434\u0432\u043e\u0434\u044f \u0438\u0442\u043e\u0433: \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 <code>VoiceManager<\/code> \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 <code>Voice<\/code>, \u043e\u043d \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0444\u0443\u043d\u043a\u0446\u0438\u044e <code>reset<\/code> \u0434\u043b\u044f \u0441\u0431\u0440\u043e\u0441\u0430 \u0433\u043e\u043b\u043e\u0441\u0430 \u0434\u043e \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f. \u042d\u0442\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u0435\u0442 \u043e\u0441\u0446\u0438\u043b\u043b\u044f\u0442\u043e\u0440\u044b \u0433\u043e\u043b\u043e\u0441\u0430, \u0435\u0433\u043e \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u044b \u043e\u0433\u0438\u0431\u0430\u044e\u0449\u0438\u0445 \u0438 \u0444\u0438\u043b\u044c\u0442\u0440.<\/p>\n<h3>static \u0438\u043b\u0438 \u043d\u0435 static?<\/h3>\n<p>  \u041f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0447\u043b\u0435\u043d\u044b \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0433\u043e\u043b\u043e\u0441\u043e\u0432 \u043e\u0434\u043d\u0438 \u0438 \u0442\u0435 \u0436\u0435:<\/p>\n<ul>\n<li><code>Oscillator<\/code>: <code>mOscillatorMode <\/code><\/li>\n<li><code>Filter<\/code>: <code>cutoff<\/code>, <code>resonance<\/code>, <code>mode<\/code><\/li>\n<li><code>EnvelopeGenerator<\/code>: <code>stageValue<\/code><\/li>\n<\/ul>\n<p>  \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u044f \u0434\u0443\u043c\u0430\u043b, \u0447\u0442\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u0430\u044f \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u044d\u0442\u043e \u0437\u043b\u043e, \u0438 \u0432\u0441\u0435 \u044d\u0442\u0438 \u0448\u0442\u0443\u043a\u0438 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438 \u0447\u043b\u0435\u043d\u0430\u043c\u0438. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e <code>mOscillatorMode<\/code> \u2014 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439. \u0422\u043e\u0433\u0434\u0430 \u0443 LFO \u0431\u044b\u043b\u0430 \u0431\u044b \u0442\u0430 \u0436\u0435 \u0444\u043e\u0440\u043c\u0430 \u0432\u043e\u043b\u043d\u044b, \u0447\u0442\u043e \u0438 \u0443 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u043e\u0441\u0446\u0438\u043b\u043b\u044f\u0442\u043e\u0440\u043e\u0432, \u0430 \u044d\u0442\u043e\u0433\u043e \u043c\u044b \u043d\u0435 \u0445\u043e\u0442\u0438\u043c. \u0414\u0430\u043b\u0435\u0435, \u0435\u0441\u043b\u0438 \u0431\u044b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <code>stageValue<\/code> \u0433\u0435\u043d\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u043e\u0433\u0438\u0431\u0430\u044e\u0449\u0438\u0445 <code>EnvelopeGenerator<\/code> \u0431\u044b\u043b\u0438 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c\u0438, \u043e\u0433\u0438\u0431\u0430\u044e\u0449\u0438\u0435 \u0430\u043c\u043f\u043b\u0438\u0442\u0443\u0434\u044b \u0438 \u0444\u0438\u043b\u044c\u0442\u0440\u0430 \u0431\u044b\u043b\u0438 \u0431\u044b \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c\u0438.<\/p>\n<p>  \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0438\u0441\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u043f\u0443\u0442\u0435\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f: \u0441\u043e\u0437\u0434\u0430\u0432 \u043a\u043b\u0430\u0441\u0441\u044b <code>VolumeEnvelope<\/code> \u0438 <code>FilterEnvelope<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043b\u0438 \u0431\u044b \u043e\u0442 \u043a\u043b\u0430\u0441\u0441\u0430 <code>EnvelopeGenerator<\/code>. \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>stageValue<\/code> \u043c\u043e\u0433 \u0431\u044b \u0431\u044b\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0438 <code>VolumeEnvelope<\/code> \u0438 <code>FilterEnvelope<\/code> \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u0435\u0433\u043e \u043c\u0435\u043d\u044f\u0442\u044c. \u042d\u0442\u043e \u0447\u0435\u0442\u043a\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043b\u043e \u0431\u044b \u043e\u0433\u0438\u0431\u0430\u044e\u0449\u0438\u0435 \u0438 \u0432\u0441\u0435 \u0433\u043e\u043b\u043e\u0441\u0430 \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u0438\u043c\u0435\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0447\u043b\u0435\u043d\u0430\u043c. \u041d\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0440\u0435\u0447\u044c \u043d\u0435 \u0438\u0434\u0435\u0442 \u043e \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043e\u0431\u044a\u0435\u043c\u0430\u0445 \u043f\u0430\u043c\u044f\u0442\u0438. \u0412\u0441\u0435, \u0447\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u0438 \u0442\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u043e\u0437\u0434\u0430\u043b\u0438 \u043c\u044b, \u044d\u0442\u043e \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043c\u0435\u0436\u0434\u0443 \u043e\u0433\u0438\u0431\u0430\u044e\u0449\u0438\u043c\u0438 \u0430\u043c\u043f\u043b\u0438\u0442\u0443\u0434 \u0438 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432 \u0432\u0441\u0435\u0445 \u0433\u043e\u043b\u043e\u0441\u043e\u0432.<\/p>\n<p>  \u041e\u0434\u043d\u0430\u043a\u043e \u043e\u0434\u043d\u0430 \u0432\u0435\u0449\u044c \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439: <code>sampleRate<\/code>. \u041d\u0435\u0442 \u0441\u043c\u044b\u0441\u043b\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0441\u0438\u043d\u0442\u0435\u0437\u0430\u0442\u043e\u0440\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u0447\u0430\u0441\u0442\u043e\u0442\u0430\u0445 \u0434\u0438\u0441\u043a\u0440\u0435\u0442\u0438\u0437\u0430\u0446\u0438\u0438. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0434\u043f\u0440\u0430\u0432\u0438\u043c \u044d\u0442\u043e \u0432 <i>Oscillator.h<\/i>:<\/p>\n<pre><code class=\"cpp\">static double mSampleRate; <\/code><\/pre>\n<p>  \u0410 \u0437\u043d\u0430\u0447\u0438\u0442, \u043c\u044b \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u0447\u0435\u0440\u0435\u0437 \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. \u0423\u0434\u0430\u043b\u0438\u0442\u0435 <code>mSampleRate(44100.0)<\/code>. \u0412 <i>Oscillator.cpp<\/i> \u043f\u043e\u0441\u043b\u0435 <code>#include<\/code> \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435:<\/p>\n<pre><code class=\"cpp\">double Oscillator::mSampleRate = 44100.0; <\/code><\/pre>\n<p>  \u0427\u0430\u0441\u0442\u043e\u0442\u0430 \u0434\u0438\u0441\u043a\u0440\u0435\u0442\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0438 \u0432\u0441\u0435 \u043e\u0441\u0446\u0438\u043b\u043b\u044f\u0442\u043e\u0440\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u043e\u0434\u043d\u043e \u0435\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<br \/>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0442\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0434\u043b\u044f <code>EnvelopeGenerator<\/code>. \u0421\u0434\u0435\u043b\u0430\u0439\u0442\u0435 <code>sampleRate<\/code> \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c, \u0443\u0434\u0430\u043b\u0438\u0442\u0435 \u0438\u0437 \u0441\u043f\u0438\u0441\u043a\u0430 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u0438 \u0434\u043e\u043f\u0438\u0448\u0438\u0442\u0435 \u0432 <i>EnvelopeGenerator.cpp<\/i>:<\/p>\n<pre><code class=\"cpp\">double EnvelopeGenerator::sampleRate = 44100.0; <\/code><\/pre>\n<p>  \u0412 <i>EnvelopeGenerator.h<\/i> \u0441\u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0441\u0435\u0442\u0442\u0435\u0440:<\/p>\n<pre><code class=\"cpp\">static void setSampleRate(double newSampleRate); <\/code><\/pre>\n<p>  \u041c\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u043c\u043d\u043e\u0433\u043e \u043d\u043e\u0432\u043e\u0433\u043e! \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0440\u0430\u0437 \u043c\u044b \u043f\u043e\u0447\u0438\u0441\u0442\u0438\u043c \u043b\u0438\u0448\u043d\u0435\u0435 \u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043c GUI \u0432 \u0440\u0430\u0431\u043e\u0447\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435.<\/p>\n<p>  \u041a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c <a href=\"http:\/\/martin-finke.de\/blog\/articles\/audio-plugins-016-polyphony\/source.zip\">\u043e\u0442\u0441\u044e\u0434\u0430<\/a>. <br \/>  <a href=\"http:\/\/martin-finke.de\/blog\/articles\/audio-plugins-016-polyphony\/\">\u041e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u043f\u043e\u0441\u0442\u0430<\/a>.      \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/231513\/\"> http:\/\/habrahabr.ru\/post\/231513\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">     \t\u0412\u0441\u0435 \u043f\u043e\u0441\u0442\u044b \u0441\u0435\u0440\u0438\u0438:<br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/224911\/\">\u0427\u0430\u0441\u0442\u044c 1. \u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430<\/a><br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/225019\/\">\u0427\u0430\u0441\u0442\u044c 2. \u0418\u0437\u0443\u0447\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0430<\/a><br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/225457\/\">\u0427\u0430\u0441\u0442\u044c 3. VST \u0438 AU<\/a><br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/225751\/\">\u0427\u0430\u0441\u0442\u044c 4. \u0426\u0438\u0444\u0440\u043e\u0432\u043e\u0439 \u0434\u0438\u0441\u0442\u043e\u0440\u0448\u043d<\/a><br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/225755\/\">\u0427\u0430\u0441\u0442\u044c 5. \u041f\u0440\u0435\u0441\u0435\u0442\u044b \u0438 GUI<\/a><br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/226439\/\">\u0427\u0430\u0441\u0442\u044c 6. \u0421\u0438\u043d\u0442\u0435\u0437 \u0441\u0438\u0433\u043d\u0430\u043b\u043e\u0432<\/a><br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/226573\/\">\u0427\u0430\u0441\u0442\u044c 7. \u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 MIDI \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439<\/a><br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/226823\/\">\u0427\u0430\u0441\u0442\u044c 8. \u0412\u0438\u0440\u0442\u0443\u0430\u043b\u044c\u043d\u0430\u044f \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u0430<\/a><br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/227475\/\">\u0427\u0430\u0441\u0442\u044c 9. \u041e\u0433\u0438\u0431\u0430\u044e\u0449\u0438\u0435<\/a><br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/227601\/\">\u0427\u0430\u0441\u0442\u044c 10. \u0414\u043e\u0440\u0430\u0431\u043e\u0442\u043a\u0430 GUI<\/a><br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/227791\/\">\u0427\u0430\u0441\u0442\u044c 11. \u0424\u0438\u043b\u044c\u0442\u0440<\/a><br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/227827\/\">\u0427\u0430\u0441\u0442\u044c 12. \u041d\u0438\u0437\u043a\u043e\u0447\u0430\u0441\u0442\u043e\u0442\u043d\u044b\u0439 \u043e\u0441\u0446\u0438\u043b\u043b\u044f\u0442\u043e\u0440<\/a><br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/228267\/\">\u0427\u0430\u0441\u0442\u044c 13. \u0420\u0435\u0434\u0438\u0437\u0430\u0439\u043d<\/a><br \/>  <a href=\"http:\/\/habrahabr.ru\/post\/231513\/\">\u0427\u0430\u0441\u0442\u044c 14. \u041f\u043e\u043b\u0438\u0444\u043e\u043d\u0438\u044f 1<\/a>  <\/p>\n<hr\/>\n<p>  \u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u043f\u043e\u043b\u0438\u0444\u043e\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0441\u0438\u043d\u0442\u0435\u0437\u0430\u0442\u043e\u0440\u0430 \u0438\u0437 \u0442\u0435\u0445 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0443 \u043d\u0430\u0441 \u0438\u043c\u0435\u044e\u0442\u0441\u044f!<\/p>\n<p>  \u0412 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437 \u043c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u043d\u0430\u0434 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u043c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u043e\u043c, \u0441\u0435\u0433\u043e\u0434\u043d\u044f \u043c\u044b \u043d\u0430\u0447\u043d\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u0443 \u043d\u0430\u0434 \u043b\u0435\u0436\u0430\u0449\u0435\u0439 \u0432 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u043b\u0430\u0433\u0438\u043d\u0430 <a href=\"https:\/\/en.wikipedia.org\/wiki\/Polyphony_and_monophony_in_instruments\">\u043f\u043e\u043b\u0438\u0444\u043e\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u0439<\/a> \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u043e\u0439 \u0430\u0443\u0434\u0438\u043e. \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0438\u0433\u0440\u0430\u0442\u044c \u0434\u043e 64-\u0445 \u043d\u043e\u0442 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e. \u042d\u0442\u043e \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043e\u0441\u043d\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 \u043f\u043b\u0430\u0433\u0438\u043d\u0430, \u043d\u043e \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0443\u0436\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u043d\u0430\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u044b <code>Oscillator<\/code>, <code>EnvelopeGenerator<\/code>, <code>MIDIReceiver<\/code> \u0438 <code>Filter<\/code>.<\/p>\n<p>  \u0412 \u044d\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u0435 \u043c\u044b \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u043a\u043b\u0430\u0441\u0441 <code>Voice<\/code> (\u0433\u043e\u043b\u043e\u0441), \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0438\u0439 \u043e\u0434\u043d\u0443 \u0437\u0432\u0443\u0447\u0430\u0449\u0443\u044e \u043d\u043e\u0442\u0443. \u0417\u0430\u0442\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043b\u0430\u0441\u0441 <code>VoiceManager<\/code>, \u0441\u043b\u0435\u0434\u044f\u0449\u0438\u0439 \u0437\u0430 \u0442\u0435\u043c, \u0447\u0442\u043e\u0431\u044b \u0432\u0441\u0435 \u043d\u043e\u0442\u044b \u0437\u0432\u0443\u0447\u0430\u043b\u0438 \u0438 \u0437\u0430\u0433\u043b\u0443\u0448\u0430\u043b\u0438\u0441\u044c \u0432\u043e\u0432\u0440\u0435\u043c\u044f.<br \/>  \u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043f\u043e\u0441\u0442\u0435 \u043c\u044b \u043f\u043e\u0447\u0438\u0441\u0442\u0438\u043c \u043a\u043e\u0434 \u043e\u0442 \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0445 \u0443\u0441\u0442\u0430\u0440\u0435\u0432\u0448\u0438\u0445 \u0447\u0430\u0441\u0442\u0435\u0439, \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043c\u043e\u0434\u0443\u043b\u044f\u0446\u0438\u044e \u0442\u043e\u043d\u0430 \u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u0430 \u0432 \u0440\u0430\u0431\u043e\u0447\u0435\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435. \u041d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u043e\u043b\u043d\u043e. \u041d\u043e \u0432\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0443 \u043d\u0430\u0441 \u0443\u0436\u0435 \u0435\u0441\u0442\u044c \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432\u0441\u0435 \u043d\u0443\u0436\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b, \u0430 \u0432\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u0432 \u043a\u043e\u043d\u0446\u0435 \u0443 \u043d\u0430\u0441 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439-\u043f\u043e\u043b\u0438\u0444\u043e\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0439-\u0441\u0443\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u0438\u0432\u043d\u044b\u0439-\u0431\u043b\u0438\u043d-\u0441\u0438\u043d\u0442\u0435\u0437\u0430\u0442\u043e\u0440!<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-231513","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/231513","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=231513"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/231513\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=231513"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=231513"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=231513"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}