aener Posted November 7, 2011 Report Share Posted November 7, 2011 Hello. First off - I'm not asking you to do my maths homework for me. Those days are over I need to make an expression of some sort to calculate a variable to use in a piece of software. I'm making a software instrument, and one of the important aspects of the sound is a reverse-type sound, where the ending is more important than the beginning. I have a 4000ms sound file, which is exactly the right length at 120BPM (eight beats/two bars). Obviously, when it's a faster BPM, I'll need to get it to start playing X milliseconds in to the sample so that it arrives at the end of the sample after two bars and vice versa I've found a few values manually, but I need an expression so that when the user sets the BPM to whatever value they want, it'll work out how many milliseconds to leave before playing or chop off the start. Here are the values: BPM MS 60 -4000 80 -2000 100 -800 120 0 180 1333 240 2000 320 2400 If not having to deal with negatives makes it much easier, I can happily alter the sample to become 4000ms longer, and set 60bpm to the minimum. Been looking around for a while now. I can make a graph to show the trend, but I need to be able to calculate reasonably precisely the length of time with the BPM input. The short version: What is/how do I determine the equation of an inverse quadratic graph (specifically, the values listed above)? Really hope someone can help. It's the only thing holding me up at the minute. Quote Link to comment Share on other sites More sharing options...
monkeyseemonkeydo Posted November 7, 2011 Report Share Posted November 7, 2011 I'm with you right up until you mention BPM, bars etc... If it were just maths I'd be all over it but I have no clue whatsoever about bars and musicy shiznitz. Quote Link to comment Share on other sites More sharing options...
MonsieurMonkey Posted November 7, 2011 Report Share Posted November 7, 2011 Surely whatever software you're using to make the graph can give you the equation of the graph? Giving you the equation to work out any variable at any number? Quote Link to comment Share on other sites More sharing options...
Luke Rainbird Posted November 7, 2011 Report Share Posted November 7, 2011 About to eat, will get on it later on. Essentially you just want an equation that fits those points listed, yeah? 1 Quote Link to comment Share on other sites More sharing options...
monkeyseemonkeydo Posted November 7, 2011 Report Share Posted November 7, 2011 About to eat, will get on it later on. Essentially you just want an equation that fits those points listed, yeah? It doesn't work though, well, not as a quadratic anyway... 1 Quote Link to comment Share on other sites More sharing options...
aener Posted November 7, 2011 Author Report Share Posted November 7, 2011 I'm with you right up until you mention BPM, bars etc... If it were just maths I'd be all over it but I have no clue whatsoever about bars and musicy shiznitz. Well that's not particularly important anyway - that was just the context of the problem. If you can solve the problem without the context the super-kudos to you! Surely whatever software you're using to make the graph can give you the equation of the graph? Giving you the equation to work out any variable at any number? I made a graph in Excel - I looked around for ages for how to do that, but couldn't find it anywhere. About to eat, will get on it later on. Essentially you just want an equation that fits those points listed, yeah? Yeah - that's exactly it. It doesn't work though, well, not as a quadratic anyway... A quadratic was just a guess from the rough shape of it. Don't know much about different types of lineation (if that's even a word), logarithmic? Whatever... I don't mind what it is, so long as I can express it in a language based around C. (Not the crazy triple layered things they have in the movies ) Quote Link to comment Share on other sites More sharing options...
MonsieurMonkey Posted November 7, 2011 Report Share Posted November 7, 2011 (edited) The equation you need is on the graph monkeyseemonkeydo posted. I'll just throw in an I think, because I'm not 100% sure. Edited November 7, 2011 by MonsieurMonkey Quote Link to comment Share on other sites More sharing options...
monkeyseemonkeydo Posted November 7, 2011 Report Share Posted November 7, 2011 Is that table in the first post definitely correct for what you need? Quote Link to comment Share on other sites More sharing options...
aener Posted November 7, 2011 Author Report Share Posted November 7, 2011 (edited) Is that table in the first post definitely correct for what you need? I'll check them again now, but I'm pretty sure. Would +4000ing make the task any easier? Can do that no trouble at all. Edit: that line you gave is the same one Excel gave me. I was hoping I'd done something wrong and that wasn't actually what I wanted. Edited November 7, 2011 by aener Quote Link to comment Share on other sites More sharing options...
monkeyseemonkeydo Posted November 7, 2011 Report Share Posted November 7, 2011 I'll check them again now, but I'm pretty sure. I'm just asking because the deltas up to 120 are 20 and then you jump to 60, 60, 80 which seemed a bit odd. Quote Link to comment Share on other sites More sharing options...
aener Posted November 7, 2011 Author Report Share Posted November 7, 2011 (edited) Ah right - no... they were just the BPMs I could be bothered to find out by actually changing it and lining up manually. Would more be helpful? If it gets a decent result I don't mind rinsing a bunch of time on it. You were right though - the last one should be 2498 if that makes a difference. Looks like we'd've prefered it to go 98 the other way though Edited November 7, 2011 by aener Quote Link to comment Share on other sites More sharing options...
Luke Rainbird Posted November 7, 2011 Report Share Posted November 7, 2011 Food = done. To clarify (I'm a mathematician first, so only really interested in the data rather than the context ) you just need an equation that fits the data points you gave? Does it matter how nasty the equation is? More nasty = better to use in terms of results, but obviously the more difficult it is to input into your code (and to an extent how long it'll take to compute when the program is run) What are the likely highest and lowest bpm's that you need to consider? 1 Quote Link to comment Share on other sites More sharing options...
Pete.M Posted November 7, 2011 Report Share Posted November 7, 2011 I think you'd need three equations. One for the relationship between deltas of 20, one for deltas of 60, and another for 80. But I can't say for sure. Quote Link to comment Share on other sites More sharing options...
Luke Rainbird Posted November 7, 2011 Report Share Posted November 7, 2011 Simply approximating the curve we can use a relatively straightforward equation along the lines of delay = (4000*bpm-480000)/bpm (quick play, think the numbers are out etc) Though as we get to the edge of the data that starts to become a tad less accurate. In the range it works nicely though Knowing the extremes of the range needed, we can tailor it a little so that this doesn't really matter though 1 Quote Link to comment Share on other sites More sharing options...
aener Posted November 7, 2011 Author Report Share Posted November 7, 2011 (edited) Food = done. To clarify (I'm a mathematician first, so only really interested in the data rather than the context ) you just need an equation that fits the data points you gave? Does it matter how nasty the equation is? More nasty = better to use in terms of results, but obviously the more difficult it is to input into your code (and to an extent how long it'll take to compute when the program is run) What are the likely highest and lowest bpm's that you need to consider? It should be pretty simple so it'll run without any lag, but then it can be pretty nasty (up to a point). Something that'll give a return within +-50mS as a maximum should be fine, though within 10mS would be ideal. In the interest of helping you guys to help me, I did some extras (please note the correction I made in an above comment is also in here.) 60 -4000 80 -2000 100 -800 120 0 140 569 160 995 180 1333 200 1598 220 1815 240 2000 260 2152 280 2283 300 2400 320 2498 Thanks for this. "Lifesaver" is an appropriate term, I think. Edit: Majority of BPM usage will be in the 80-200 range. I put in the higher values in case it made calculating the curve easier. Edit2: Is that graph in the latter post the one from "delay = (4000*bpm-480000)/bpm"? It looks pretty damned close in the most likely uses! Edited November 7, 2011 by aener Quote Link to comment Share on other sites More sharing options...
Luke Rainbird Posted November 7, 2011 Report Share Posted November 7, 2011 Also, how are you working these figures out? From looking at samples, or actually calculating them? (Just checking ) Edit; for the larger data set, you can get a pretty sweet fitting curve with the ever-beautiful (-217011263383818731520000000000000+20664951892000*bpm^9-12392812046640000*bpm^8+4892969910611040000*bpm^7-1338281636930851200000*bpm^6+259702831214200320000000*bpm^5-35989303531473433600000000*bpm^4+3531455833478489292800000000*bpm^3-238423910848138543104000000000*bpm^2+10245929262227560857600000000000*bpm-20394445340*bpm^10+9019743*bpm^11)/(6649130495508480000000000000+171898365542400000000000*bpm^2-67422207541248000000000000*bpm) So obviously this is where we need to find the limit between having a nice simple function, or having a more accurate one Edit2; better throw in the graph. My bad! 1 Quote Link to comment Share on other sites More sharing options...
aener Posted November 7, 2011 Author Report Share Posted November 7, 2011 Also, how are you working these figures out? From looking at samples, or actually calculating them? (Just checking ) I've got the sample in question in a DAW, changing the BPM, lining the end of the sample up with a bar line, going back two bars, the number of mS on the readout of that minus the mS when cursor's on the start of the sample. That make sense? I can draw a picture if not Quote Link to comment Share on other sites More sharing options...
Luke Rainbird Posted November 7, 2011 Report Share Posted November 7, 2011 Yep, makes sense. In which case yeah, we need to work out what an acceptable limit for variation is (ie. what the most you can 'get away with' is before the samples sound out to your ear). Remember there'll be a small error somewhere in reading off the data too, but should be near negligible on this kinda scale I'd have thought. 1 Quote Link to comment Share on other sites More sharing options...
aener Posted November 7, 2011 Author Report Share Posted November 7, 2011 Something that'll give a return within +-50mS as a maximum should be fine, though within 10mS would be ideal. Whatever you've using to get these figures... Can you pick a figure and state how much it estimates? I'll check it against the way I've been doing it in the DAW. Sample's a reversy-type sound anyway, so got a bit of leeway thanks to that. Quote Link to comment Share on other sites More sharing options...
Luke Rainbird Posted November 7, 2011 Report Share Posted November 7, 2011 Sure Taking something at the slower end of the scale as this will be where the largest errors will be (the faster you get, the less noticeable it'll be) For a sample played at 65bpm this would give a delay of -3386.10ms. Edit; think I've made a typo, let me double check this function a sec Edit2; nope, seems pretty tight 1 Quote Link to comment Share on other sites More sharing options...
aener Posted November 7, 2011 Author Report Share Posted November 7, 2011 (edited) Sure Taking something at the slower end of the scale as this will be where the largest errors will be (the faster you get, the less noticeable it'll be) For a sample played at 65bpm this would give a delay of -3386.10ms. Edit; think I've made a typo, let me double check this function a sec Edit2; nope, seems pretty tight I got (Edit: -)3387, and mine rounds off to the nearest mS. I'd say that's pretty bang on. Was that the big complex'n'nasty one? Edited November 7, 2011 by aener Quote Link to comment Share on other sites More sharing options...
Luke Rainbird Posted November 7, 2011 Report Share Posted November 7, 2011 It was indeed. The simpler function gave a delay of -3384.62ms, so isn't exactly a million miles out either If you're able to try with both functions, give both a whirl and see if there's any noticeable computational lag when you run the sortware. I wouldn't have thought there'd be much, but you can decide then whether or not you need the raw accuracy or if the considerably simpler equation will cut the mustard (which it probably will) 1 Quote Link to comment Share on other sites More sharing options...
aener Posted November 7, 2011 Author Report Share Posted November 7, 2011 It was indeed. The simpler function gave a delay of -3384.62ms, so isn't exactly a million miles out either If you're able to try with both functions, give both a whirl and see if there's any noticeable computational lag when you run the sortware. I wouldn't have thought there'd be much, but you can decide then whether or not you need the raw accuracy or if the considerably simpler equation will cut the mustard (which it probably will) Excellent. Many many many loves for you. I posted that thinking it was hopeless, and that I'd have to sign up to a maths forum and get told I was a f**king idiot a million times over. Thanks! I'll let you know how it goes. Had more than enough for today, but when I do it... Quote Link to comment Share on other sites More sharing options...
Luke Rainbird Posted November 7, 2011 Report Share Posted November 7, 2011 No worries. I can now sleep easy knowing that my degree has been useful at least once in my life 1 Quote Link to comment Share on other sites More sharing options...
JDâ„¢ Posted November 7, 2011 Report Share Posted November 7, 2011 No worries. I can now sleep easy knowing that my degree has been useful at least once in my life You haven't heard the final result yet.... (Flipp: ) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.