{"@attributes":{"version":"2.0"},"channel":{"title":"Matt Tytel","description":"Matt Tytel - personal website\n","link":"https:\/\/tytel.org\/","pubDate":"Thu, 21 Apr 2022 13:25:53 +0100","lastBuildDate":"Thu, 21 Apr 2022 13:25:53 +0100","generator":"Jekyll v3.8.6","item":[{"title":"New Synth in the Works","description":"<p><a href=\"https:\/\/vital.audio\">I\u2019m working on a new synth!<\/a><\/p>\n\n","pubDate":"Mon, 19 Feb 2018 12:30:00 +0000","link":"https:\/\/tytel.org\/blog\/2018\/02\/19\/new-synth\/","guid":"https:\/\/tytel.org\/blog\/2018\/02\/19\/new-synth\/","category":["blog","devblog"]},{"title":"Stickers!","description":"<p>I got some stickers printed of the new logo! If you PayPal me $5 at\n<a href=\"mailto:matthewtytel@gmail.com\">matthewtytel@gmail.com<\/a> and mention the\nstickers and include your address I\u2019ll send you one :D<\/p>\n\n<p><img src=\"\/static\/images\/blog\/stickers.jpg\" alt=\"Helm Stickers\" \/><\/p>\n\n<p>Since the synth is free this is a way of generating some (small) amount of\nmonetary support.<\/p>\n\n<p>I got these die cut stickers through Sticker Mule. They make super high quality\nvinyl stickers that are water\/sun\/scratch resistant. They can even go through\nthe dishwasher.<\/p>\n\n<p>Dimensions are about 3in x 3in.<\/p>\n","pubDate":"Mon, 01 Jun 2015 13:30:00 +0100","link":"https:\/\/tytel.org\/blog\/2015\/06\/01\/stickers\/","guid":"https:\/\/tytel.org\/blog\/2015\/06\/01\/stickers\/","category":["blog","devblog","helm"]},{"title":"Experiments with Material Design","description":"<p>I\u2019ve done a lot of UI changes with <a href=\"https:\/\/github.com\/mtytel\/helm\">Helm<\/a> lately based off this\nnew design idea called <a href=\"https:\/\/www.google.com\/design\/spec\/material-design\/\">Material Design<\/a>. You should go check\nit out yourself, but the basic idea is you take flat UI design and organize\nit in layers like pieces of paper. The result is a combination of bold colors\nand skeuomorphic shadows.<\/p>\n\n<p>The shadows gave me pause, at first it felt like the 90\u2019s again where you slap\na drop shadow on everything. After looking through Google\u2019s examples and\napplying many of their ideas to Helm, I have to say that I\u2019m now a born-again\ndrop shadow believer. They make colors really pop and are a great way to\nemphasize how important certain elements are.<\/p>\n\n<p><img src=\"\/static\/images\/blog\/shadows.png\" alt=\"Helm Shadows\" \/><\/p>\n\n<p><img src=\"\/static\/images\/blog\/shadows2.png\" alt=\"Helm Shadows\" \/><\/p>\n\n<p>Google\u2019s design doc is pretty funny when they mention <em>how<\/em> to implement the\nshadows. They say you shouldn\u2019t approximate the shadows with gradients or\nimages. Instead they say, render the shadows with a 3d graphics engine. I\n<em>guess<\/em> I get it, when you have multiple layers overlapping the gradients won\u2019t\nlook right, but I don\u2019t know many people who can hire a team of developers\nto develop a rendering engine just so the shadows look accurate!<\/p>\n\n<p>After the shadows, the <a href=\"https:\/\/www.google.com\/design\/spec\/style\/color.html\">color<\/a> section has been the most\nhelp in designing Helm. If you get overwhelmed with all the combinations of\npossible color palettes like I do, then using Google\u2019s method for picking\ncolors is a good place to start. They hit a good balance of restricting the\ncolors enough so whatever combination you pick should look decent while also\nhaving enough colors and shades so not every app using this method will look\nthe same.<\/p>\n\n<p>If you care about design and want some guidelines to follow I highly recommend\ngiving the whole <a href=\"https:\/\/www.google.com\/design\/spec\/material-design\/\">Material Design<\/a> doc a read. They hit on a\nlot of other topics like animation, layout and widgits that all have decent\ninsight on what looks good and what doesn\u2019t.<\/p>\n\n","pubDate":"Sun, 17 May 2015 13:30:00 +0100","link":"https:\/\/tytel.org\/blog\/2015\/05\/17\/material-design\/","guid":"https:\/\/tytel.org\/blog\/2015\/05\/17\/material-design\/","category":["blog","devblog","helm","features"]},{"title":"Rebranding - Helm","description":"<p>I\u2019m rebranding Twytch! First the name: Twytch was a little\ntoo similar to the video streaming service \u2018Twitch\u2019 and so after playing around\nwith some logos and names I\u2019ve decided on \u2018Helm\u2019. It conveys control, a common\ntheme in synthesizers, it\u2019s short and easy to remember, and I can\u2019t find other\nsoftware that uses the name except for an emacs plugin.<\/p>\n\n<p>The other part is a new icon\/logo. Graphic design is something I spend a lot of\ntime on but doesn\u2019t come natural to me. After many hours I think I have a logo\nI\u2019m happy with. Here\u2019s the development in reverse chronological order.<\/p>\n\n<h3 id=\"i-think-its-more-cute-than-cool-and-im-good-with-that\"><strong>I think it\u2019s more cute than cool and I\u2019m good with that:<\/strong><\/h3>\n<p><img src=\"\/static\/images\/blog\/helm_logo6.png\" alt=\"Helm Logo 6\" \/><\/p>\n\n<h3 id=\"got-to-helmet-stage-but-didnt-like-the-shadows-and-square-nose\"><strong>Got to \u2018helmet\u2019 stage, but didn\u2019t like the shadows and square nose:<\/strong><\/h3>\n<p><img src=\"\/static\/images\/blog\/helm_logo5.png\" alt=\"Helm Logo 5\" \/><\/p>\n\n<h3 id=\"flipped-it-its-almost-a-helmet-and-less-of-a-plug\"><strong>Flipped it, it\u2019s almost a helmet and less of a plug:<\/strong><\/h3>\n<p><img src=\"\/static\/images\/blog\/helm_logo4.png\" alt=\"Helm Logo 4\" \/><\/p>\n\n<h3 id=\"i-like-the-cuts-of-the-yellow-circle-being-align-with-the-blue-circle\"><strong>I like the cuts of the yellow circle being align with the blue circle:<\/strong><\/h3>\n<p><img src=\"\/static\/images\/blog\/helm_logo3.png\" alt=\"Helm Logo 3\" \/><\/p>\n\n<h3 id=\"getting-away-from-that-phallic-design\"><strong>Getting away from that phallic design:<\/strong><\/h3>\n<p><img src=\"\/static\/images\/blog\/helm_logo2.png\" alt=\"Helm Logo 2\" \/><\/p>\n\n<h3 id=\"trying-a-different-flat-bold-outline-style\"><strong>Trying a different flat, bold, outline style:<\/strong><\/h3>\n<p><img src=\"\/static\/images\/blog\/helm_logo1.png\" alt=\"Helm Logo 1\" \/><\/p>\n\n<h3 id=\"first-design-its-supposed-to-be-a-plug-pretty-phallic-though\"><strong>First design, it\u2019s supposed to be a plug. Pretty phallic though:<\/strong><\/h3>\n<p><img src=\"\/static\/images\/blog\/helm_logo0.png\" alt=\"Helm Logo 0\" \/><\/p>\n\n","pubDate":"Fri, 08 May 2015 13:30:00 +0100","link":"https:\/\/tytel.org\/blog\/2015\/05\/08\/rebranding-to-helm\/","guid":"https:\/\/tytel.org\/blog\/2015\/05\/08\/rebranding-to-helm\/","category":["blog","devblog","helm"]},{"title":"Unexpected Optimization #2: fixed point arithmetic","description":"<p>I\u2019ve wanted to add a \u2018unison\u2019 feature to Twytch for a while but without a\nsignificant performance hit. Unison works by having many oscillators per voice\nso improving the oscillator CPU usage was a must.<\/p>\n\n<p>The way many oscillator implementations work is by having a \u2018phasor\u2019 which is\na phase value that cycles through the values from 0 to 1. When the phase value\nis 0, we are at the beginning of the waveform, 0.5 we\u2019re half way through and\nwhen we get to 1, we\u2019re at the end and we set the value back to 0. Checking if\nwe have to wrap the phase every sample for every oscillator can get pretty\ncostly. One way to improve this is by using the modf function instead of a\ncomparison and an if\/else branch but it still is has a relatively large CPU\nhit.<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-c--\" data-lang=\"c++\"><span class=\"kt\">int<\/span> <span class=\"n\">table_size<\/span> <span class=\"o\">=<\/span> <span class=\"mi\">2048<\/span><span class=\"p\">;<\/span>\n<span class=\"kt\">double<\/span> <span class=\"n\">phase<\/span> <span class=\"o\">=<\/span> <span class=\"mf\">0.0<\/span><span class=\"p\">;<\/span>\n<span class=\"kt\">double<\/span> <span class=\"n\">phase_diff<\/span> <span class=\"o\">=<\/span> <span class=\"p\">...;<\/span> <span class=\"c1\">\/\/ Usually we don't know what value this is.<\/span>\n\n<span class=\"k\">for<\/span> <span class=\"p\">(<\/span><span class=\"kt\">int<\/span> <span class=\"n\">i<\/span> <span class=\"o\">=<\/span> <span class=\"mi\">0<\/span><span class=\"p\">;<\/span> <span class=\"n\">i<\/span> <span class=\"o\">&lt;<\/span> <span class=\"n\">samples<\/span><span class=\"p\">;<\/span> <span class=\"o\">++<\/span><span class=\"n\">i<\/span><span class=\"p\">)<\/span> <span class=\"p\">{<\/span>\n  <span class=\"n\">phase<\/span> <span class=\"o\">+=<\/span> <span class=\"n\">phase_diff<\/span><span class=\"p\">;<\/span>\n  <span class=\"k\">if<\/span> <span class=\"p\">(<\/span><span class=\"n\">phase<\/span> <span class=\"o\">&gt;=<\/span> <span class=\"mf\">1.0<\/span><span class=\"p\">)<\/span>\n    <span class=\"n\">phase<\/span> <span class=\"o\">-=<\/span> <span class=\"mf\">1.0<\/span><span class=\"p\">;<\/span>\n\n  <span class=\"c1\">\/\/ Lookup value with phase. No interpolation for this example.<\/span>\n  <span class=\"kt\">int<\/span> <span class=\"n\">index<\/span> <span class=\"o\">=<\/span> <span class=\"n\">phase<\/span> <span class=\"o\">*<\/span> <span class=\"n\">table_size<\/span><span class=\"p\">;<\/span>\n  <span class=\"n\">output_buffer<\/span><span class=\"p\">[<\/span><span class=\"n\">i<\/span><span class=\"p\">]<\/span> <span class=\"o\">=<\/span> <span class=\"n\">lookup<\/span><span class=\"p\">[<\/span><span class=\"n\">index<\/span><span class=\"p\">];<\/span>\n<span class=\"p\">}<\/span>\n\n<span class=\"c1\">\/\/ Alternatively with modf which is slightly more efficient.<\/span>\n<span class=\"kt\">double<\/span> <span class=\"n\">integral_part<\/span> <span class=\"o\">=<\/span> <span class=\"mf\">0.0<\/span><span class=\"p\">;<\/span>\n<span class=\"k\">for<\/span> <span class=\"p\">(<\/span><span class=\"kt\">int<\/span> <span class=\"n\">i<\/span> <span class=\"o\">=<\/span> <span class=\"mi\">0<\/span><span class=\"p\">;<\/span> <span class=\"n\">i<\/span> <span class=\"o\">&lt;<\/span> <span class=\"n\">samples<\/span><span class=\"p\">;<\/span> <span class=\"o\">++<\/span><span class=\"n\">i<\/span><span class=\"p\">)<\/span> <span class=\"p\">{<\/span>\n  <span class=\"n\">phase<\/span> <span class=\"o\">=<\/span> <span class=\"n\">modf<\/span><span class=\"p\">(<\/span><span class=\"n\">phase<\/span> <span class=\"o\">+<\/span> <span class=\"n\">phase_diff<\/span><span class=\"p\">,<\/span> <span class=\"o\">&amp;<\/span><span class=\"n\">integral_part<\/span><span class=\"p\">);<\/span>\n\n  <span class=\"c1\">\/\/ Lookup value with phase. No interpolation for this example.<\/span>\n  <span class=\"kt\">int<\/span> <span class=\"n\">index<\/span> <span class=\"o\">=<\/span> <span class=\"n\">phase<\/span> <span class=\"o\">*<\/span> <span class=\"n\">table_size<\/span><span class=\"p\">;<\/span>\n  <span class=\"n\">output_buffer<\/span><span class=\"p\">[<\/span><span class=\"n\">i<\/span><span class=\"p\">]<\/span> <span class=\"o\">=<\/span> <span class=\"n\">lookup<\/span><span class=\"p\">[<\/span><span class=\"n\">index<\/span><span class=\"p\">];<\/span>\n<span class=\"p\">}<\/span><\/code><\/pre><\/figure>\n\n<p>There\u2019s another solution though and it\u2019s using \u2018fixed-point\u2019 instead of\n\u2018floating-point\u2019 numbers. Floating point numbers can represent a crazy large\nrange of numbers but for our phasor implementation we only care about number\nbetween 0 and 1. What we can do is use an unsigned integer type to represent\nthese values. 0 will still remain the beginning of our waveform, but\nUINT_MAX will represent the end of our waveform. Cool thing about integers\nis that when we add to our phase and go past UINT_MAX, we get the wrapping\nfor free! Another benefit is if our wave lookup table is a power of two, we\ncan get the lookup index by bit shifting our current phase down which is\nanother (albeit small) performance improvement.<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-c--\" data-lang=\"c++\"><span class=\"kt\">int<\/span> <span class=\"n\">table_bits<\/span> <span class=\"o\">=<\/span> <span class=\"mi\">11<\/span><span class=\"p\">;<\/span>\n<span class=\"kt\">int<\/span> <span class=\"n\">shift<\/span> <span class=\"o\">=<\/span> <span class=\"mi\">8<\/span> <span class=\"o\">*<\/span> <span class=\"k\">sizeof<\/span><span class=\"p\">(<\/span><span class=\"kt\">int<\/span><span class=\"p\">)<\/span> <span class=\"o\">-<\/span> <span class=\"n\">table_bits<\/span><span class=\"p\">;<\/span>\n<span class=\"kt\">int<\/span> <span class=\"n\">phase<\/span> <span class=\"o\">=<\/span> <span class=\"mi\">0<\/span><span class=\"p\">;<\/span>\n<span class=\"kt\">int<\/span> <span class=\"n\">phase_diff<\/span> <span class=\"o\">=<\/span> <span class=\"p\">...;<\/span> <span class=\"c1\">\/\/ Usually we don't know what value this is.<\/span>\n\n<span class=\"k\">for<\/span> <span class=\"p\">(<\/span><span class=\"kt\">int<\/span> <span class=\"n\">i<\/span> <span class=\"o\">=<\/span> <span class=\"mi\">0<\/span><span class=\"p\">;<\/span> <span class=\"n\">i<\/span> <span class=\"o\">&lt;<\/span> <span class=\"n\">samples<\/span><span class=\"p\">;<\/span> <span class=\"o\">++<\/span><span class=\"n\">i<\/span><span class=\"p\">)<\/span> <span class=\"p\">{<\/span>\n  <span class=\"c1\">\/\/ Automatially wraps :D<\/span>\n  <span class=\"n\">phase<\/span> <span class=\"o\">+=<\/span> <span class=\"n\">phase_diff<\/span><span class=\"p\">;<\/span>\n\n  <span class=\"c1\">\/\/ One bit shift is more efficient than a multiply and cast I believe.<\/span>\n  <span class=\"kt\">int<\/span> <span class=\"n\">index<\/span> <span class=\"o\">=<\/span> <span class=\"n\">phase<\/span> <span class=\"o\">&gt;&gt;<\/span> <span class=\"n\">shift<\/span><span class=\"p\">;<\/span>\n  <span class=\"n\">output_buffer<\/span><span class=\"p\">[<\/span><span class=\"n\">i<\/span><span class=\"p\">]<\/span> <span class=\"o\">=<\/span> <span class=\"n\">lookup<\/span><span class=\"p\">[<\/span><span class=\"n\">index<\/span><span class=\"p\">];<\/span>\n<span class=\"p\">}<\/span><\/code><\/pre><\/figure>\n\n<p>After this improvement I\u2019m would say the DSP is at a releasable efficiency.\nComparing Twytch to other similar synths on the commercial market, it\u2019s in the\nmiddle of the pack. The next thing I\u2019ll be focusing on is improving the UI\nefficiency as there are a lot of moving parts in Twytch and most of them are\nnot CPU friendly.<\/p>\n\n","pubDate":"Fri, 01 May 2015 13:30:00 +0100","link":"https:\/\/tytel.org\/blog\/2015\/05\/01\/unexpected-optimization-02\/","guid":"https:\/\/tytel.org\/blog\/2015\/05\/01\/unexpected-optimization-02\/","category":["blog","devblog","twytch","optimization"]},{"title":"Long Update","description":"<p>Whew, it\u2019s been a while and a lot has changed! I\u2019ve decided to make\n<a href=\"https:\/\/github.com\/mtytel\/twytch\">Twytch<\/a> a free and open source project releasing it under GNU. My new\ngoal is to make a very accessible free synth that runs on most platforms.\nBecause of this I\u2019ve cut back a lot of the more experimental features like\nglitches in place of more established ones like unison and a powerful\nmodulation system.<\/p>\n\n<p>The new modulation system is heavily inspired by Bitwig Studio though I don\u2019t\nthink they were the original creators of this type of system. I\u2019ll talk more\nabout how it works in a different post.<\/p>\n\n<p>I\u2019ve made a bunch of changes to the UI and there\u2019s a lot more coming! I find\ngoing back through the iterations entertaining so I\u2019m posting them all here.\nThe most recent changes are inspired by <a href=\"https:\/\/www.google.com\/design\/spec\/material-design\/\">Material Design<\/a>\nwhich has heavy shadow usage. I used to think drop shadows were pretty\noutdated, but when combined with a flat UI, it looks really fresh.<\/p>\n\n<p>Here are the UI screenshots in reverse chronological order:<\/p>\n\n<h3 id=\"material-design-attempt-1-and-new-colors-look-at-dem-shadows\"><strong>Material design attempt 1 and new colors. Look at dem shadows:<\/strong><\/h3>\n<p><img src=\"\/static\/images\/blog\/2015-04-23-screenshot.png\" alt=\"Twytch Screenshot 4-23\" \/><\/p>\n\n<h3 id=\"no-more-borders\"><strong>No more borders:<\/strong><\/h3>\n<p><img src=\"\/static\/images\/blog\/2015-04-14-screenshot.png\" alt=\"Twytch Screenshot 4-14\" \/><\/p>\n\n<h3 id=\"trying-out-some-new-colors\"><strong>Trying out some new colors:<\/strong><\/h3>\n<p><img src=\"\/static\/images\/blog\/2015-04-01-screenshot.png\" alt=\"Twytch Screenshot 4-01\" \/><\/p>\n\n<h3 id=\"im-not-sure-if-i-want-this-entire-synth-to-be-purple\"><strong>I\u2019m not sure if I want this entire synth to be purple:<\/strong><\/h3>\n<p><img src=\"\/static\/images\/blog\/2015-03-20-screenshot.png\" alt=\"Twytch Screenshot 3-20\" \/><\/p>\n\n<h3 id=\"prototyping-widgits\"><strong>Prototyping widgits:<\/strong><\/h3>\n<p><img src=\"\/static\/images\/blog\/2015-01-18-screenshot.png\" alt=\"Twytch Screenshot 1-18\" \/><\/p>\n\n","pubDate":"Thu, 23 Apr 2015 13:30:00 +0100","link":"https:\/\/tytel.org\/blog\/2015\/04\/23\/long-update\/","guid":"https:\/\/tytel.org\/blog\/2015\/04\/23\/long-update\/","category":["blog","devblog","twytch"]},{"title":"Unexpected Optimization #1: avoiding denormals","description":"<p>I\u2019ve been noticing a strange spike in CPU usage while playing\nwith <a href=\"https:\/\/github.com\/mtytel\/twytch\">Twytch<\/a>. When a synth voice rings out and is not producing sound\nanymore, it is killed and reused later to save CPU cycles. However, there\u2019s\na significant increase in CPU usage right before a voice dies. For a while\nthis was a mystery, but I was recently reading <a href=\"https:\/\/github.com\/vinniefalco\/DSPFilters\">some filter code in another\nproject<\/a> that added a very small alternating current to the input\nof the filter. In the comment it said \u201cHack to prevent denormals\u201d.<\/p>\n\n<p>A <a href=\"https:\/\/en.wikipedia.org\/wiki\/Denormal_number\">denormal<\/a> is a type of really small floating point number.\nWikipedia give a better explanation, but in short the structure of floating\npoint numbers cause the gap from 0 to the smallest positive number to be much\nlarger than the gap between the two smallest positive numbers. Architectures\ncompensate for this by setting aside some numbers that are more evenly spaced\nreally close to zero called \u201cdenormal numbers\u201d or \u201csubnormal numbers\u201d. The\nproblem with this in synth development, is that processing subnormal numbers\nis much slower than normal floating point numbers. Since we create really\nsmall numbers any time there\u2019s an exponential decay like in an envelope or a\nfilter, we need to disable denormals.<\/p>\n\n<p>The alternative to having denormals is flushing those numbers to zero. Since\nthese numbers are so small these jumps are imperceptible in an audio signal.\nAll we have to do is slap an environment variable setting and we should be good\nto go! (on some machines)<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-c--\" data-lang=\"c++\"><span class=\"cp\">#include &lt;fenv.h&gt;\n<\/span><span class=\"c1\">\/\/ ...<\/span>\n<span class=\"n\">fesetenv<\/span><span class=\"p\">(<\/span><span class=\"n\">FE_DFL_DISABLE_SSE_DENORMS_ENV<\/span><span class=\"p\">);<\/span><\/code><\/pre><\/figure>\n\n","pubDate":"Tue, 10 Feb 2015 12:30:00 +0000","link":"https:\/\/tytel.org\/blog\/2015\/02\/10\/unexpected-optimization-01\/","guid":"https:\/\/tytel.org\/blog\/2015\/02\/10\/unexpected-optimization-01\/","category":["blog","devblog","twytch","optimization"]},{"title":"Unexpected Optimization #0: at() vs operator[]","description":"<p>Writing a soft synth requires a lot of optimization. As I develop\n<a href=\"https:\/\/github.com\/mtytel\/twytch\">twytch<\/a> and the synth engine it\u2019s built on, <a href=\"https:\/\/github.com\/mtytel\/mopo\">mopo<\/a>, I\u2019ll be\nposting many of the optimizations I make, especially nonobvious ones. These\ncould range from simple things like using one-multiply instead of\ntwo-multiply interpolation:<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-c--\" data-lang=\"c++\"><span class=\"c1\">\/\/ These lines compute the same value.<\/span>\n<span class=\"kt\">double<\/span> <span class=\"n\">one_multiply<\/span> <span class=\"o\">=<\/span> <span class=\"n\">from<\/span> <span class=\"o\">+<\/span> <span class=\"n\">t<\/span> <span class=\"o\">*<\/span> <span class=\"p\">(<\/span><span class=\"n\">to<\/span> <span class=\"o\">-<\/span> <span class=\"n\">from<\/span><span class=\"p\">);<\/span>  <span class=\"c1\">\/\/ 1 multiply and 2 adds<\/span>\n<span class=\"kt\">double<\/span> <span class=\"n\">two_multiply<\/span> <span class=\"o\">=<\/span> <span class=\"n\">t<\/span> <span class=\"o\">*<\/span> <span class=\"n\">to<\/span> <span class=\"o\">+<\/span> <span class=\"p\">(<\/span><span class=\"mi\">1<\/span> <span class=\"o\">-<\/span> <span class=\"n\">t<\/span><span class=\"p\">)<\/span> <span class=\"o\">*<\/span> <span class=\"n\">from<\/span><span class=\"p\">;<\/span> <span class=\"c1\">\/\/ 2 multiplies and 2 adds<\/span><\/code><\/pre><\/figure>\n\n<p>Or could be uglier solutions like embedding assembly instructions in C++.\nI\u2019m not a C++ optimization expert yet, so some of these things may be more\nobvious than others.<\/p>\n\n<p>This first unexpected optimization concerns accessing values from std::vector.\nConsider these two methods of element access:<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-c--\" data-lang=\"c++\"><span class=\"n\">std<\/span><span class=\"o\">::<\/span><span class=\"n\">vector<\/span><span class=\"o\">&lt;<\/span><span class=\"kt\">double<\/span><span class=\"o\">&gt;<\/span> <span class=\"n\">vect<\/span> <span class=\"o\">=<\/span> <span class=\"p\">...;<\/span>\n<span class=\"kt\">double<\/span> <span class=\"n\">one<\/span> <span class=\"o\">=<\/span> <span class=\"n\">vect<\/span><span class=\"p\">[<\/span><span class=\"mi\">0<\/span><span class=\"p\">];<\/span>\n<span class=\"kt\">double<\/span> <span class=\"n\">two<\/span> <span class=\"o\">=<\/span> <span class=\"n\">vect<\/span><span class=\"p\">.<\/span><span class=\"n\">at<\/span><span class=\"p\">(<\/span><span class=\"mi\">0<\/span><span class=\"p\">);<\/span><\/code><\/pre><\/figure>\n\n<p>There is a significant difference between the two: at() does boundary checking\nwhile operator[] does not. You don\u2019t normally notice this performance\ndifference, but I was running it once per audio sample for every single\ncomponent which totaled in the millions per second.<\/p>\n\n<p>Now why would I use at() instead of operator[] in\nthe first place? The way mopo sets up polyphony is that all the module\ninstances in each voice share a list of input pointers. For example, every\nFilter instance in each poice has a pointer to the same std::vector. Using at()\non a pointer to std::vector is much easier to read than using operator[] or\ndereferencing first so I first chose the slower but prettier method.<\/p>\n\n<figure class=\"highlight\"><pre><code class=\"language-c--\" data-lang=\"c++\"><span class=\"n\">std<\/span><span class=\"o\">::<\/span><span class=\"n\">vector<\/span><span class=\"o\">&lt;<\/span><span class=\"kt\">double<\/span><span class=\"o\">&gt;*<\/span> <span class=\"n\">pvect<\/span> <span class=\"o\">=<\/span> <span class=\"k\">new<\/span> <span class=\"n\">std<\/span><span class=\"o\">::<\/span><span class=\"n\">vector<\/span><span class=\"o\">&lt;<\/span><span class=\"kt\">double<\/span><span class=\"o\">&gt;<\/span><span class=\"p\">();<\/span>\n<span class=\"n\">pvect<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">push_back<\/span><span class=\"p\">(<\/span><span class=\"mf\">1.0<\/span><span class=\"p\">);<\/span>\n\n<span class=\"kt\">double<\/span> <span class=\"n\">slow<\/span> <span class=\"o\">=<\/span> <span class=\"n\">pvect<\/span><span class=\"o\">-&gt;<\/span><span class=\"n\">at<\/span><span class=\"p\">(<\/span><span class=\"mi\">0<\/span><span class=\"p\">);<\/span>          <span class=\"c1\">\/\/ easy to read but slow.<\/span>\n<span class=\"kt\">double<\/span> <span class=\"n\">fast1<\/span> <span class=\"o\">=<\/span> <span class=\"n\">pvect<\/span><span class=\"o\">-&gt;<\/span><span class=\"k\">operator<\/span><span class=\"p\">[](<\/span><span class=\"mi\">0<\/span><span class=\"p\">);<\/span> <span class=\"c1\">\/\/ fast ugly access 1<\/span>\n<span class=\"kt\">double<\/span> <span class=\"n\">fast2<\/span> <span class=\"o\">=<\/span> <span class=\"p\">(<\/span><span class=\"o\">*<\/span><span class=\"n\">pvect<\/span><span class=\"p\">)[<\/span><span class=\"mi\">0<\/span><span class=\"p\">];<\/span>          <span class=\"c1\">\/\/ fast ugly access 2<\/span><\/code><\/pre><\/figure>\n\n<p>Fortunately switching from at() to operator[] an easy thing to fix, and I got a\nsignificant 25% speed boost because of it.<\/p>\n\n","pubDate":"Mon, 19 Jan 2015 12:30:00 +0000","link":"https:\/\/tytel.org\/blog\/2015\/01\/19\/unexpected-optimization-00\/","guid":"https:\/\/tytel.org\/blog\/2015\/01\/19\/unexpected-optimization-00\/","category":["blog","devblog","twytch","optimization"]},{"title":"Starting Development on Twytch, an open source synthesizer","description":"<p>On the 1st day of 2015, I started development on an open source software synth, <a href=\"https:\/\/github.com\/mtytel\/twytch\">Twytch<\/a>. I\u2019ve decided to keep a devblog after seeing some of the devblog successes in the indie game development world such as <a href=\"http:\/\/willychyr.com\/blog\/\">Willy Chyr\u2019s Relativity<\/a> and <a href=\"http:\/\/fractgame.com\/news\">Phosfiend Systems\u2019 Fract OSC<\/a>.<\/p>\n\n<p>The goal of Twytch is a mix of granular and subtractive synthesis that focuses on glitching live and sampled audio input. It currently runs as a VST and Audio Unit and hopefully will run as a stand-alone synthesizer in the future. Some of the technologies I\u2019m using are:<\/p>\n\n<ul>\n  <li><a href=\"https:\/\/www.juce.com\/\">JUCE<\/a>: for cross platform UI development and VST\/AU input and output handling<\/li>\n  <li><a href=\"https:\/\/github.com\/mtytel\/mopo\">mopo<\/a>: a modular and polyphonic synthesizer engine I\u2019m working on<\/li>\n<\/ul>\n\n<p>I started with the code from a past synthesizer I made called <a href=\"https:\/\/www.gnu.org\/software\/cursynth\/\">cursynth<\/a>. It\u2019s this goofy stand-alone ascii synth that runs inside of a terminal with ascii sliders and graphics. From the past weeks of work I have a functioning Audio Unit synthesizer and the beginnings of many of the UI elements. There\u2019s also very cumbersome patch saving and loading, but it works. I\u2019m now at that point in development where you just throw all the controls on the screen and make an ugly UI soup. Have a look:<\/p>\n\n<p><img src=\"\/static\/images\/blog\/2015-01-18-screenshot.png\" alt=\"Twytch Screenshot\" \/><\/p>\n\n","pubDate":"Sun, 18 Jan 2015 04:59:06 +0000","link":"https:\/\/tytel.org\/blog\/2015\/01\/18\/twytch-intro\/","guid":"https:\/\/tytel.org\/blog\/2015\/01\/18\/twytch-intro\/","category":["blog","devblog","twytch"]},{"title":"Stray Bolts","description":"<p>Not born for courts and chains<br \/>\nand pendulums swinging up and down,<br \/>\nthrough granada\u2019s royal town.<br \/>\nWe softly, slowly dance,<br \/>\nlistening for murmured murmurs.<\/p>\n\n<p>Our vanity endows us<br \/>\nthough neither foe nor friend allow us,<br \/>\nto hear the force of that murderous deed,<br \/>\nthat made love bleed.<\/p>\n\n<p>To know sometimes we run to madness,<br \/>\nin thoughtless throngs and empty noise.<br \/>\nShall truth with fiction, our world of bloom<br \/>\npreserve what it first creates?<\/p>\n","pubDate":"Sun, 06 Jan 2013 00:00:00 +0000","link":"https:\/\/tytel.org\/poetry\/stray-bolts\/","guid":"https:\/\/tytel.org\/poetry\/stray-bolts\/","category":"poems"}]}}