Podcast Search

Under the Radar

185: Advanced Math

Select a time to play from there. The line being spoken is highlighted as the audio plays.

0:00:00Welcome to Under the Radar,

0:00:01a show about independent iOS app development.

0:00:04I'm Marco Arment.

0:00:05- And I'm David Smith.

0:00:06Under the Radar is never longer than 30 minutes,

0:00:08so let's get started.

0:00:09- So Dave, I don't know about you,

0:00:11but in school, I was really good at math,

0:00:14only up to a certain point.

0:00:18Maybe like middle of high school.

0:00:20Once we started getting into more advanced math topics,

0:00:24like I think for me the boundary was calculus.

0:00:27I didn't take calculus till college,

0:00:28and I was terrible at it, and I failed it twice,

0:00:32and never went and retook it,

0:00:33and never really learned calculus.

0:00:35I failed linear algebra also twice,

0:00:37doing advanced matrix operations and stuff like that,

0:00:40and never retook that, never fixed that.

0:00:44Anything involving really advanced calculations like that,

0:00:47that wasn't just basically combinations of basic,

0:00:51the basic four calculator operations,

0:00:53or stuff like that.

0:00:55I was very bad at, or never learned,

0:00:58or tried to learn and failed at.

0:01:00And yet we work in a field where our tools

0:01:04are super fast math machines that do what we tell them to,

0:01:08and that we often need math for.

0:01:12And I think it's funny that a lot of programming

0:01:15does indeed need math, but it's mostly the simpler math

0:01:19that I was really good at already.

0:01:20It's mostly elementary, middle, and maybe high school math.

0:01:24But it's not, most programmers don't have to do things

0:01:27like calculus or linear algebra, or theory proofs

0:01:31and everything like that in their regular work,

0:01:33or any of their work really.

0:01:34I think those are specialties.

0:01:36But I do occasionally run into some need

0:01:39for a better understanding of math than what I have.

0:01:45And I'm curious, does this happen to you too,

0:01:48and how do you solve it?

0:01:50- Yes, so A, it happens all the time.

0:01:53And it is like one of the,

0:01:56it's almost like a running joke in my house,

0:01:57where all of a sudden, it's sort of like a scene

0:01:59out of Beautiful Mind, and my desk just becomes

0:02:01just strewn with papers, filled with scrawled formulas

0:02:05all over the place, because I'm not particularly,

0:02:08yeah, I had a similar experience with math.

0:02:10I can do, through Algebra II trig,

0:02:13was sort of like, I think I took,

0:02:17that was the last level of math where,

0:02:20and I feel like that's the level of where math

0:02:22is still intuitive to some degree,

0:02:25but it's based on tangible, understandable things,

0:02:29in a way that like addition, when you teach it to a child,

0:02:32is like, I have one apple, and I get another apple,

0:02:36how many apples do I have?

0:02:37It's like, well, you have two.

0:02:39And there's an intuitive and like a,

0:02:42something concrete that you can wrap your head around.

0:02:44And then you get to a certain point in math,

0:02:46and it stops being that.

0:02:49And it becomes this much more abstract,

0:02:53sort of theoretical thing that I can sort of understand,

0:02:57that in calculus, what you're doing is you're calculating

0:03:00the area under a curve, or the slope of a line.

0:03:04That is fundamentally what most of calculus is doing.

0:03:08But just knowing that that's functionally what you're doing,

0:03:12actually how you go about doing that,

0:03:15very quickly becomes this totally abstract concept,

0:03:19where how do you know what the slope of a sine curve is?

0:03:22And it's like, well, that's like through deep magic.

0:03:26I don't know.

0:03:26All I learned at a certain point was that

0:03:29this is the formula, and I can apply this formula,

0:03:32and I can get the right answer.

0:03:33But I never had a intuitive understanding

0:03:36of anything beyond, yeah, that's sort of like

0:03:38that algebra two trig area.

0:03:40Like trigonometry is where it starts to kind of,

0:03:43I'm hitting the limit where I understand that I'm like,

0:03:46the ratio between two lengths of a triangle,

0:03:51that that ratio is related to the angle of the corner,

0:03:54and things like that.

0:03:55Like it's sort of concrete and sort of understandable,

0:03:58but beyond that, it kind of falls apart.

0:04:00But this happens all the time.

0:04:03And I feel like often what is most kind of frustrating

0:04:07is that this math shows up in places where you can,

0:04:12it's like at this boundary between a feature being

0:04:15like all right, and a feature being really cool.

0:04:18Like there's this, if you wanted the extra flourish,

0:04:20if you wanted to be that little bit cooler,

0:04:22or do a little bit, like something a little bit fancier,

0:04:25is where the math starts to show up.

0:04:27Where the straightforward way is, you see,

0:04:31it's like that's when you're dealing with just like

0:04:32simple rectangles and moving them around

0:04:35in straightforward way.

0:04:36But if you want to have like a cool curve

0:04:38when you're doing an animation,

0:04:39or you want to make the shape of something

0:04:41not just be plain, but be sort of advanced,

0:04:46or even moreover what I've been running into

0:04:49a lot recently in my work is,

0:04:51there's a naive solution to a problem,

0:04:54and then there's the accurate solution to the problem.

0:04:58And the naive solution is really straightforward

0:05:00and easy to work with.

0:05:02But the actual solution that is like sort of correct

0:05:05in physics or correct in detail is where all of a sudden

0:05:09now I need to pull out all of the math

0:05:11and go and spend a lot of time just like researching online.

0:05:15And a lot of it is the unfortunate kind of research

0:05:17where I feel like I solve this problem a lot

0:05:20by trying to find, learn just enough

0:05:23that I can find the right formula

0:05:25that I can apply and get the right answer,

0:05:27even if I don't understand what I'm doing.

0:05:30Like there's a ton of the math that I was using

0:05:32for like my moon project where it's like,

0:05:35I don't understand, I have no idea why

0:05:38like this equation gives me the, you know,

0:05:40the longitude of the moon right now.

0:05:43But it does.

0:05:44And it works.

0:05:45And once I can like, I'm just like empirically verifying it

0:05:48and then going like finding, you know, the NASA table

0:05:51where it's like, you know, I can get a table

0:05:53that forecasts the values of certain things

0:05:55over different times.

0:05:56My values match their values like plus or minus

0:05:59a small error percent, and then I'm good.

0:06:01And I don't need to understand why the formula works

0:06:04or what's going on necessarily, but like that is,

0:06:06that is a situation that has happened

0:06:08so often to me recently.

0:06:10- Yeah, it happens to me probably every few months

0:06:13where I will be tackling a feature

0:06:15or trying to figure out, you know, some weird edge case

0:06:18or something where I will quickly realize like,

0:06:21you know what, I could use more advanced mathematical

0:06:24knowledge than what I have to solve this.

0:06:25Or I need more advanced knowledge to solve this.

0:06:28And for me, like you know, like another big hole

0:06:29in my knowledge is most kind of advanced stats

0:06:33and like data analysis.

0:06:35Like I can't do like data mining.

0:06:37I still don't understand machine learning at all.

0:06:40And I'm almost, I haven't really tried it,

0:06:43but you know, there's huge areas of that

0:06:45where I feel like I either have fallen behind

0:06:48or was never even in the race that I probably

0:06:51should familiarize myself with.

0:06:53But even, you know, basic stuff like if I'm trying

0:06:55to figure out a pattern in a bunch of data I have,

0:06:58and I'm trying to figure out like yeah,

0:06:59I can calculate like the average and stuff.

0:07:01But if I try to go beyond that, to be like all right,

0:07:04what if I like, you know, try to find clusters

0:07:06of meaningful data or I try to find, try to, you know,

0:07:09rule out the outliers and you know, focus only

0:07:12on the middle, like that's all like much more

0:07:15advanced math than anything I ever actually

0:07:17officially learned.

0:07:18And sometimes you can take advantage of libraries

0:07:21or functions or formulas you can find online

0:07:23to do it for you.

0:07:25Sometimes you just kind of fudge it and you kind of like,

0:07:27all right, well, I guess I'll figure out how to do this

0:07:30myself with the knowledge I have without actually

0:07:33looking up the right way to do it.

0:07:35And sometimes you can get an approximate solution

0:07:36that kind of works.

0:07:37Sometimes you accidentally come upon the actual solution

0:07:40without even realizing it, although that's less common.

0:07:43And I find that like a lot of times the kind of like

0:07:48half fake hack solution that you kind of stumble upon

0:07:52by doing it naively is often good enough

0:07:55and is often fast enough.

0:07:56And in fact, there's lots of methods that you can find

0:08:00online of like, of you know, major apps or especially games.

0:08:03Games often take a lot of shortcuts for performance

0:08:06where they did some kind of rough approximation

0:08:09of something and that proved to be good enough

0:08:13or close enough for their purposes.

0:08:15And that saved them either from having to know

0:08:19a more advanced version or saved the computing time

0:08:21of the computer having to do a more advanced version.

0:08:24- Yeah, and that good enough is such a, like,

0:08:26I feel like in weird ways, like, 'cause part of me

0:08:30as a developer, I enjoy solving like the hard problem

0:08:33and doing it well.

0:08:34Like, that's part of what I like doing.

0:08:37But it's so often the, like, is this, it's like the increase

0:08:41in effort to have the correct answer versus a close answer

0:08:45is, you know, is wildly disproportionate.

0:08:50Like I was thinking recently, I was doing a thing.

0:08:52So I, you know, I had, if you imagine you're trying to show

0:08:55the color and associate it with a temperature, you know,

0:08:58so this is for like a weather display.

0:09:00Like in some ways, like the first version of this that I did

0:09:04was a, like I just did the super naive version

0:09:07where if you take the hue of like, you know,

0:09:10it starts like a hue zero or in, you know, in UI color.

0:09:15And that's red.

0:09:18And if you go up to about like 220-ish, that's like blue.

0:09:23And in between it goes like red, orange, yellow, green

0:09:27to blue, like it's, you know, sort of as you would expect.

0:09:29And the super simple version I did initially was just like,

0:09:32well, I'll take like the temperature in,

0:09:36and say I do it like in Fahrenheit from zero to 120,

0:09:40work out like what percent of that is,

0:09:42and then just like map that onto the hue.

0:09:44And so when it's really hot, it'll be, you know, red.

0:09:47And then when it's really cold, it'll be really blue.

0:09:50And like that sort of works.

0:09:51But then I started, you start to get like,

0:09:53well, what if I wanted to make it a little bit like,

0:09:55like have a more consistent visual appearance to it

0:09:59or have a more, like a thoughtful,

0:10:02or like I could have different points along the way.

0:10:05Well, then I need to start to be getting

0:10:06into like color blending.

0:10:07And color blending is this whole crazy,

0:10:10like you see one of these things,

0:10:11like you open the first box,

0:10:13like you pick the book off the shelf that says color blending

0:10:16and you're like, oh, that's interesting.

0:10:17And you can just like, the first version is just do like,

0:10:19you know, I pick the points along the curve

0:10:21that I want the colors to be,

0:10:23and then I'll just do like a linear interpolation

0:10:24between like the RGB values at each point,

0:10:27which like mostly works.

0:10:30But then you can have these weird like middle,

0:10:31mid points in between your interpolations

0:10:33where like the color isn't really what you want,

0:10:35but that is like the color that you just asked for,

0:10:38where you were, what you really start to get into,

0:10:40like then you get into like color perception

0:10:42and how people are sensitive to different colors

0:10:44at different intensities.

0:10:47So, so like a yellow and a blue and a red,

0:10:51like at a constant hue, if you keep the saturation

0:10:54and like the brightness the same,

0:10:56like one of them will look darker than the other.

0:10:58And so you can end up with these weird cases

0:11:00where if you're just blending between them,

0:11:02like it looks as though the color is getting like brighter

0:11:04and darker in weird and uncomfortable ways.

0:11:08And that's because of the way people perceive color.

0:11:11That is, you know, way,

0:11:13all of a sudden you're starting to get like,

0:11:14even beyond math, you're starting to get into like biology

0:11:16and the way that the rods and cones in your eyes work.

0:11:19And it's like, at a certain point, it's like, okay,

0:11:21I'm just gonna close this book

0:11:23and I'm gonna start with the simple version again,

0:11:26because the effort to get it perceptually correct

0:11:29has probably now over, like exceeded the actual increase

0:11:33in quality that I would get by opening up this math.

0:11:36And like, that's an example where like,

0:11:37I ended up going with a fairly simple version

0:11:40that kind of mostly works

0:11:41and doesn't deal with all the weird image perception issues,

0:11:44but gives me a pretty good answer

0:11:46that looks pretty good most of the time.

0:11:49And it's like, okay.

0:11:50Or you can do the other classic thing where in programming,

0:11:53where I find like I often will take,

0:11:55like there's a weird place that my 80% solution works,

0:12:00but except for like in this, you know,

0:12:01in this temperature case,

0:12:02it's like except for between 60 and 70 degrees,

0:12:06my color looks wrong.

0:12:07And so I just like have an if statement

0:12:09that if the temperature is between 60 and 70,

0:12:12change it in this way.

0:12:13That's not like mathematically correct.

0:12:15It's not like this beautiful, smooth curve.

0:12:17And if you really look closely between like, you know,

0:12:19this like one degree, one way, one degree the other,

0:12:22you can notice this, you know, discontinuity in the curve.

0:12:25It's like, you know, like you could,

0:12:27but I only ever display like one color

0:12:29on the screen at a time, so you know, it's probably fine.

0:12:33And like that's this kind of,

0:12:34this place where you find where you're trying to like,

0:12:36where on this math spectrum do I actually wanna be?

0:12:39Like do I wanna go like go crazy down the rabbit hole

0:12:43and then come up on the other side

0:12:44with this perfect solution that is like technically correct?

0:12:48Or do I want something that's, you know,

0:12:49mostly good and looks fine?

0:12:52- I mean, and you know, an example like that,

0:12:54like you could even do something even dumber and simpler,

0:12:57you just have a lookup table

0:12:58for like integer temperature values.

0:13:00Because does it really matter

0:13:02if you have a slightly different color

0:13:05for 60 degrees versus 60.5 degrees?

0:13:08- Sure.

0:13:09- Like it probably doesn't matter that much.

0:13:10I bet nobody would ever notice.

0:13:12And so you could actually just like run the basic formula,

0:13:15get the colors, map them to a lookup table

0:13:17for each temperature scale, and then just look at it

0:13:19and say like, which of these look wrong?

0:13:20And then just manually adjust the ones

0:13:22like for those buckets.

0:13:24And it would be a heck of a lot faster in performance.

0:13:26It wouldn't really cost you much memory.

0:13:28And it would actually be a reasonable solution

0:13:31to that problem since in this particular application,

0:13:34you don't need a smooth blending between intervals.

0:13:38Because no one is dragging a slider around,

0:13:41adjusting the temperature in a smooth floating point domain

0:13:45and making it so that they have to see

0:13:47these nice little gradients going.

0:13:49And like you actually could do

0:13:50something even simpler than that.

0:13:52I feel like there's a lot of cases like that

0:13:54where we have opportunities for simplification

0:13:58or optimization like that that we don't think about

0:14:01'cause we want like the theoretically best solution.

0:14:03Like this function, it won't work for floating point values

0:14:08in this certain range here.

0:14:09But it's like okay, well do you ever have those?

0:14:11Or does it matter if you just round those

0:14:13to the nearest integer first and then do the operation?

0:14:15And in a whole bunch of applications,

0:14:17the answer is no, it doesn't matter.

0:14:18Just make it work for what you will ever actually see.

0:14:23And if it doesn't quite look right

0:14:24or doesn't quite draw right for these really weird edge cases

0:14:28that literally your app will never, it should never happen,

0:14:31it doesn't really matter

0:14:32whether it was theoretically right or not.

0:14:34- Yeah, and the lookup table example I think is a great one.

0:14:36Like I also, it makes me think of,

0:14:38with all my moon calculations,

0:14:40at one point what I was trying to do

0:14:42is show the timing of the new and full moons in the app.

0:14:48So you can say like essentially jump,

0:14:50but you can kind of jump forward in time

0:14:52and know like when is the actual next full moon gonna occur?

0:14:56And I went down the rabbit hole of trying to work out

0:14:58like how do you calculate that?

0:15:00And it turns out it is just like, it's not even a book.

0:15:03It's like a collection of books and 17 people's lives

0:15:07to try and understand how you calculate when this is.

0:15:11And I go down this road for like maybe half a day.

0:15:13And in the end, I just like realize,

0:15:16okay, NASA has published a list of the full and new moon

0:15:21for the next hundred years.

0:15:24I'll grab like 10 years of those

0:15:25and just take the number that NASA has calculated

0:15:28and just hard code it in the app.

0:15:30And if I wanna know when the next one is,

0:15:31I'll just see like when's the next,

0:15:32when's the one greater than my current one?

0:15:35And I just have, I think I go 10 years into the future

0:15:38and it's like, well, in 10 years,

0:15:39the app will stop working in that particular way.

0:15:41And either I will have fixed it and extended it

0:15:44or the app won't exist or I won't care.

0:15:46And like that, like, or similarly,

0:15:50I did the same thing for like lunar eclipses,

0:15:52which is like something like,

0:15:53it worked out well in that particular case

0:15:55'cause like lunar eclipses, there aren't one for a while,

0:15:57so I don't need to worry about that particular feature.

0:15:59But when it does become our niche,

0:16:00I'll just hard code the values

0:16:01because I know when they're supposed to happen.

0:16:03Rather than like trying to calculate

0:16:06based on your current coordinate,

0:16:08what the, when you would perceive one,

0:16:09which is like a theoretically possible math problem.

0:16:13But like just hard coding the value, that worked just as well.

0:16:16- We are sponsored this week by Linode.

0:16:18Whether you're working on a personal project

0:16:19or managing your enterprise's entire infrastructure,

0:16:21Linode has the pricing, support, and scale you need

0:16:24to take your project to the next level.

0:16:26They have 11 data centers worldwide,

0:16:28including their newest data center in Sydney, Australia.

0:16:31With their enterprise-grade hardware,

0:16:32S3-compatible storage option,

0:16:34and their next generation network,

0:16:35Linode delivers the performance you expect

0:16:37at a surprisingly good price.

0:16:39I use Linode, Dave uses Linode,

0:16:41I gotta say I am super happy with it.

0:16:43I've been with them for almost a decade.

0:16:44I have all of Overcast hosted there,

0:16:46I have my personal site server hosted there.

0:16:48It's just wonderful.

0:16:50You can get started today on Linode with a $20 credit.

0:16:53You get access to native SSD storage,

0:16:55their 40 gigabit network, industry leading processors.

0:16:59You get root access to your server

0:17:00along with an API version four now

0:17:02and a Python CLI tool to automate setup if you want to.

0:17:05Their nano plans start as low as $5 a month,

0:17:08and they have lots of stuff above and beyond that

0:17:10if you have higher needs.

0:17:11Including things like dedicated CPU plans

0:17:13with physical cores reserved just for you.

0:17:15GPU compute plans, a whole bunch of other stuff.

0:17:17So, go to linode.com/radar

0:17:21and use promo code radar2020

0:17:23when creating a new Linode account.

0:17:24You get a $20 credit towards your next project.

0:17:26And by the way, they're hiring.

0:17:27If that interests you, go to linode.com/careers.

0:17:30Anyway, that URL for the $20 credit one more time

0:17:33is linode.com/radar, promo code radar2020.

0:17:37Our thanks to Linode for their support of this show

0:17:40and all of Relay FM.

0:17:41- So I've got to imagine with a lot of your sound processing,

0:17:45like there's gotta be a huge amount of math

0:17:48and like even, I mean at a certain point,

0:17:50like super complicated math,

0:17:52where you start to get into like Fourier analysis

0:17:54and the like things that are very beyond what I,

0:17:58I don't really even know which they involve,

0:18:00but I've gotta imagine things like Voice Boost 2

0:18:02that you just were working on.

0:18:04Like that's gotta involve a lot of this kind of like,

0:18:07there's a lot of theoretical math

0:18:08that you have to deal with.

0:18:09Is that something that you have to like deal with

0:18:11the actual like formulas and equations for

0:18:13or is it, at a certain point it becomes very like empirical

0:18:16and you're just comparing numbers

0:18:18and like multiplying and dividing them as needed?

0:18:21- It's interesting, like I,

0:18:23and I have no formal training in signal processing

0:18:27or anything like this and so,

0:18:29and what I have to deal with when processing sound

0:18:31is a lot of signal processing stuff.

0:18:33You know, it's stuff like filters and you know, bi-quads

0:18:38and yeah, you mentioned that the FFT, you know,

0:18:40stuff like that.

0:18:41I'm actually lucky that Overcast currently does not use

0:18:43an FFT for anything.

0:18:44The only time I've ever actually used one in Overcast

0:18:46was in the very early versions when I had like

0:18:49the peak meters that were frequency sensitive,

0:18:51the animatability artwork.

0:18:53- Sure.

0:18:54- I don't do that anymore 'cause it was a little bit

0:18:56expensive for performance and it looked a little bit

0:18:58intrusive on the screen.

0:18:59People didn't like it as much as I thought they would.

0:19:01So now I just do the little peak meters and the pause button.

0:19:04Yes, I know in the current app store version they're gone.

0:19:06Don't worry, they're coming back.

0:19:07They're in the beta right now.

0:19:09And that's just doing amplitude so I don't have to separate

0:19:11the frequency so it's much simpler.

0:19:13But I've had to learn a lot of DSP stuff.

0:19:17And fortunately, most of it is like you learn a couple

0:19:23of concepts like how you can't just apply different gain

0:19:28per sample as it's curving and expect it to sound correct

0:19:31'cause it won't.

0:19:32Or you know, things like doing basic look ahead,

0:19:35doing like attack release timing.

0:19:38But most of that is a very, very large amount of very,

0:19:41very simple map operations.

0:19:43It's you know, multiplication, it's addition.

0:19:46One of the only weird things was that sound is perceived,

0:19:51as you mentioned, like with the color example,

0:19:53like the way it's represented is with you know,

0:19:56regular values from one to zero to negative one

0:20:00as it goes like up and then back down like when you see

0:20:02the waveform graph.

0:20:04So it's like one to negative one in the float domain

0:20:06and with zero in the middle.

0:20:07But the way it's actually perceived by humans is not linear,

0:20:11it's logarithmic because of the decibel scale.

0:20:15And so I do a lot of operations in the decibel domain

0:20:19to make them sound better.

0:20:20And this is one of those examples where like,

0:20:23it doesn't, I don't really need to do it in the decimal,

0:20:26in the log domain.

0:20:27I could do it in the linear domain and it would sound okay

0:20:30and most people wouldn't notice.

0:20:31But because we perceive sound in the log domain,

0:20:35the more I could do in that domain, the better it would be.

0:20:38But also, logarithms are a complicated operation

0:20:41for computers to do.

0:20:42And so you gotta be careful like not to do too many

0:20:44conversions back and forth or not to try to like

0:20:47interpolate the log at every single point of something.

0:20:49Like there's all sorts of optimization potential.

0:20:51And there's also things like approximation functions.

0:20:55Where like, there are fast logarithm approximation

0:20:59algorithms out there that like, they get you kind of

0:21:02part of the way there.

0:21:03And sometimes that's good enough.

0:21:05Sometimes you know, if you have like,

0:21:07if your approximation is good to like three decimal places,

0:21:10like that's actually pretty good for your purposes.

0:21:12In some context it's not.

0:21:14And so there was a whole bunch of figuring that kind

0:21:19of stuff out.

0:21:20But for the most part, most of the math I'm doing is like,

0:21:23vector based, which is like, you know,

0:21:26basically look at the accelerate library

0:21:27and the VDSB functions that Apple provides.

0:21:30And it's mostly just applying the basic operations,

0:21:35like addition, subtraction, multiplication,

0:21:37to vectors of floats, which is just a fancy word

0:21:40for arrays of floats.

0:21:41So you have like a float array of like a thousand floats

0:21:44and alright, these are the next thousand samples.

0:21:45And you can say alright, what's the maximum magnitude

0:21:48of, in this thing, which is like, you know,

0:21:51basically the absolute value maximum.

0:21:53And so you can say alright, that's the peak.

0:21:55So when I'm rendering my peak samples,

0:21:57I can say alright, take a look at this next block

0:22:00and what's the maximum magnitude, VDSB max m g v, bam.

0:22:04These function names make no sense when you're first

0:22:07looking at them, but as you get used to them,

0:22:08you kind of pick up the convention.

0:22:10There is a convention.

0:22:11And so then you can rattle them off and sound really crazy.

0:22:16And then so you can call these functions on them

0:22:18and it basically like rips right through it.

0:22:20It's like these functions are so fast.

0:22:22And then I have the maximum amplitude value,

0:22:24and maximum absolute amplitude value in the next block

0:22:27of samples and that gives me my peak value

0:22:29for my peak meter display.

0:22:30So like the concepts and learning what these do

0:22:35looks intimidating from the outside because you have

0:22:36all these like mysteriously named functions

0:22:39and you're operating on very large amounts of data,

0:22:42but really what you're doing is very simple operations.

0:22:44And the challenge for me was more in learning

0:22:48like how to manipulate sound to do what I wanted

0:22:51in like basic techniques, but it wasn't so much about

0:22:54like the math behind it.

0:22:56The only exception to that is I had to do some amount

0:23:00of figuring out bi-quads, which is like a method of,

0:23:03if you ever want to implement like an EQ or frequency

0:23:07modification, the way I thought naively that you did it,

0:23:11I assumed that you would use an FFT to transfer

0:23:15from the time domain to the frequency domain,

0:23:18modify like whatever bucket you wanted a frequency,

0:23:21is like change this value from you know,

0:23:23.7 to .6, that'll drop that frequency,

0:23:25and then do an inverse FFT and put it back.

0:23:27And it turns out that isn't how you do it at all.

0:23:30You can do things that way, but it's much more complicated

0:23:33and way slower and you have to do a lot of other things

0:23:36to make it not you know, suck or distort the sound

0:23:39in weird ways.

0:23:40And so you can also use a thing called a bi-quad filter

0:23:43that is way simpler and this is what everything does.

0:23:45Like pretty much any kind of like EQ or filter thing

0:23:49that you see in apps, the iTunes EQ,

0:23:52all that stuff is just bi-quad filters.

0:23:54And I had no idea what those were or how they worked.

0:23:57And I still don't.

0:23:59I like, all I know is that I found some equations

0:24:02for how to generate like the numbers to plug into

0:24:05the bi-quad filter and there's a VDSB bi-quad function

0:24:09that does the calculation for me.

0:24:11So all I did was like how do I make these coefficients?

0:24:14And I looked up you know, certain formulas,

0:24:16alright here's how you make a notch filter,

0:24:18here's how you make a peak filter, like stuff like that.

0:24:21And then I plug it into this formula that's already there.

0:24:24So that's an example where like there is some very complex

0:24:27math behind that that I probably should know

0:24:31but I didn't have to 'cause the library took care

0:24:33of most of it for me and some you know, a few days of

0:24:37you know, web research and Stack Overflow and Google

0:24:39and stuff took care of the rest.

0:24:42- The thing you said though like the you probably should know

0:24:45like I think increasingly I don't,

0:24:48I'm not sure that's even true.

0:24:49- Hmm, that's a good point.

0:24:50Like 'cause I think there's the, this is the like,

0:24:53this is the root of this problem is it's like,

0:24:55do you need to like, do you need to understand

0:24:59the physics of leverage in order to use a hammer?

0:25:01You know like, would you be more, would you be more capable

0:25:07or wield it more efficiently if you understood the way

0:25:11of like, of the way that a lever works and like all of

0:25:14and like that type of or like the transfer of inertia?

0:25:16Like there's these things where if you understand

0:25:19the fundamental, like the underpinnings and the math

0:25:23and the physics and whatever it is of what's going on,

0:25:25like you can imagine and I can sort of, I can imagine

0:25:30myself in this pretend, like this pretend world

0:25:32where I understand this thing that I, my,

0:25:35the end result would be better.

0:25:36And like it probably would be better but almost certainly

0:25:40not by as much as you would imagine it is.

0:25:43That like I think increasingly what I find is it's like

0:25:45if I can understand something enough to know how to use it,

0:25:49and understand that there might become a point where

0:25:52there's a bug or an issue or an edge case that I can't

0:25:54deal with, like that's fine.

0:25:57But it also means that I don't have to spend like three

0:25:59years getting a PhD in the subject to like,

0:26:02because I think what I realize is you hit a point where

0:26:06the like, there's this massive chasm between the just like

0:26:10basic intuitive understanding of something and then like

0:26:13the actual deep understanding.

0:26:15And it isn't just like, oh, this is like, you know,

0:26:18a quiet afternoon sipping a cup of coffee on my porch

0:26:21reading a book.

0:26:22It's like, no, this is like, I need to go to like college

0:26:25level classes to like unpack and understand what's going on.

0:26:29You know, it's like, I don't really understand how

0:26:31Bezier paths work, like the math behind them.

0:26:35Like I remember trying to kind of get a sense of what's

0:26:37going on there.

0:26:39And it's like, I sort of could maybe get like, I was like,

0:26:42you know, could crack through like 0.1% of it.

0:26:45But at a certain point, I'm like, I don't know.

0:26:47And it's fine.

0:26:48I just like, you know, move the control point until it looks

0:26:51correct, and then that's fine.

0:26:54And like, if I truly understood the math behind it,

0:26:57maybe that would be better.

0:26:58But I get a certain point.

0:27:01Like, I think the key thing in some ways that in with,

0:27:04like in my relationship with math and my work is

0:27:06understanding that like, it's, I was there were problems

0:27:09that I was not solving, or like solutions I was ignoring

0:27:13because I thought I would have to understand it at a deep

0:27:16level in order to use it.

0:27:18And I think increasingly, it's like you, you don't need to

0:27:21necessarily understand it, you can, it's totally fine and

0:27:24legitimate to just have a working version of the solution.

0:27:28And then use that, you know, there's many things in computer

0:27:32science and in, you know, in the design of applications that

0:27:35I don't understand.

0:27:36And I don't need to understand like, I'm not really good on

0:27:39some of the graphics stuff where like, how, like,

0:27:41wave frame, frame buffers work, and the display links.

0:27:45And like, there's these things, these tools that I use when

0:27:47I'm like making an animation that I really don't understand

0:27:51that, you know, that the ins and outs of, but I understand

0:27:54enough to make it work.

0:27:56And I think that like accepting and being okay with that

0:27:59is, opens up all these problems to you that you just can,

0:28:03you can solve now.

0:28:03Like, cause if you, if you had to understand, what was it,

0:28:06bicubic?

0:28:07- Biquads.

0:28:08- Biquads.

0:28:09- Yep.

0:28:10- If you had to understand biquads in order to use biquads,

0:28:12then you probably wouldn't be using biquads and you wouldn't

0:28:15have an EQ filter and you wouldn't have features and things

0:28:18that you know, that would be available to you.

0:28:20And so I think increasingly I find like, just, it's okay.

0:28:24Just accept that this is someone else's job in the same way

0:28:27that I don't design Silicon chips, I just use them.

0:28:30Like someone else has done the hard work of coming up with

0:28:33the math and you know, they sure they got a PhD out of it.

0:28:36And they can put some letters after their name as a result,

0:28:38but I just want to, you know, use the thing and have it work.

0:28:42And that's probably good enough for me.

0:28:45- I guess I usually do feel that same way.

0:28:47That is usually my philosophy of like, you know,

0:28:49somebody else can figure out the complex mathematical

0:28:53details of this thing and I can just use it.

0:28:55It does occasionally bite you in the butt, like if something

0:28:58goes wrong or if you're having some kind of massive

0:29:00performance issue that like, and it does help to understand

0:29:04some of the underlying stuff then, but that just doesn't

0:29:07happen very often anymore.

0:29:08So you actually can just like, let someone else do the

0:29:11algorithm or the formula, figure it out, and then just

0:29:14use it.

0:29:15- Yeah, I think then that's good enough.

0:29:17And like, it's fun to use math that I learned in high school

0:29:21that at the time when I was learning it, I thought,

0:29:23why would I ever use this?

0:29:24You know, I'm never gonna use trigonometry in my real life.

0:29:27And it's like, actually I use trigonometry all the time.

0:29:29- Yeah, me too.

0:29:29- So if there's any kids listening, it's like trigonometry

0:29:32is the real stuff, make sure you learn that.

0:29:34- Yeah, right triangle trig, that's important.

0:29:37- That's important.

0:29:37- Not much after that is, but that's important.

0:29:39- That's important.

0:29:40Forget about calculus, right triangles is where it's at.

0:29:43Thanks for listening everybody, and we'll talk to you

0:29:45in two weeks.

0:29:46- Bye.

0:29:47[