Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible improvements #1

Open
benjojo opened this issue Mar 8, 2014 · 0 comments
Open

Possible improvements #1

benjojo opened this issue Mar 8, 2014 · 0 comments

Comments

@benjojo
Copy link
Owner

benjojo commented Mar 8, 2014

[17:09:32] Kai: It does look like the poly just crazy after a short amount of time, which argues that either the y scale is getting lost somewhere or it's not encoding properly after the first few samples per block
[17:13:39] Ben Cartwright Cox: Not sure how this works http://i.imgur.com/6hpBNqB.png
[17:13:50] Ben Cartwright Cox: Bottom being what it was suppose to be
[17:13:56] Kai: Yeah.
[17:14:05] Chaddock: Ben check twitter
[17:14:20] Ben Cartwright Cox: I am on twitter
[17:14:21] Ben Cartwright Cox: what look
[17:14:42] Chaddock: ffs hang on.
[17:15:32] Ben Cartwright Cox: waits
[17:17:32] Ben Cartwright Cox: https://twitter.com/haddock1000/status/442348124875784192/photo/1
[17:17:39] Ben Cartwright Cox: @kai
[17:17:53] Chaddock: There will be more in a sec.
[17:18:05] Kai: I've literally just started drawing something that looks like tjhat.
[17:18:34] Ben Cartwright Cox: http://i.imgur.com/XC4ZjZe.jpg
[17:18:42] Ben Cartwright Cox: Neak saver 1000
[17:18:45] Kai: Just did that in irfanview...
[17:18:49] Ben Cartwright Cox: god dammit
[17:18:52] Kai: ^_^
[17:19:17 | Edited 17:19:21] Kai: I was going to go ahead and draw the derivitive
[17:22:56] Kai: While I was thiking about that, I was wondering if you'd be able to have a vairiable length block
[17:24:53] Ben Cartwright Cox: Very possibily
[17:25:22 | Edited 17:25:32] Kai: Once upon a time I thought I knew how to generate a poly by knowing where d^2y/dx^2 = 0 where...
[17:25:42] Ben Cartwright Cox: We need mark
[17:25:43] Ben Cartwright Cox: :v
[17:25:53] Kai: That knowledge has atrophy'd away...
[17:25:54] Ben Cartwright Cox: mark was far too good at this black magic
[17:27:40] Chaddock: I have an idea. It is coming through now.
[17:27:58] Ben Cartwright Cox: k
[17:29:02] Ben Cartwright Cox: https://pbs.twimg.com/media/BiOMLGJIIAAigRU.jpg:large
[17:29:29] Chaddock: there should be 2
[17:29:43 | Edited 17:29:51] Ben Cartwright Cox: https://pbs.twimg.com/media/BiOMInoIUAAjWmY.jpg:large
[17:29:44] Ben Cartwright Cox: my bad
[17:30:16] Chaddock: Yeah. the algorithm is on the first one. The rest is a sort of justification of my thinking.
[17:30:46] Chaddock: now all you have to do is plot the gradient and the gradient of the gradient.
[17:30:58] Chaddock: dy/dx = 0 when the gradient is 0
[17:31:13] Chaddock: d2y/dx2 is 0 when the gradient of the gradient is 0
[17:31:37] Chaddock: zdownside is that you'll have polynomials of variable length
[17:31:47] Kai: Kinda an upside
[17:32:06] Kai: You can easiliy enough dedecate a bit to mark the start of a section
[17:32:26] Kai: It'd encode low frequencies very efficienctly.
[17:33:27] Chaddock: Yeah. High frequencies and low bit rates won't be good.
[17:33:34] Kai: Indeed
[17:33:44] Ben Cartwright Cox: Whats dy/dx V:
[17:33:46] Chaddock: but it should do that sample song.
[17:33:50] Kai: Gradiant.
[17:33:52] Ben Cartwright Cox: oh
[17:33:52] Chaddock: the gradient
[17:34:04] Chaddock: d2y/dx2 is the gradient of the gradient/
[17:34:04] Kai: So, difference between one sample and the next
[17:34:09] Ben Cartwright Cox: Ohh
[17:34:21] Kai: You'll have to set a bound near to zero, because the actuall different won't be zero,
[17:34:42 | Edited 17:34:44] Kai: So, if the gradient's lower than k, treat it as a max/min.
[17:34:54] Kai: Where k is 0.01 or something.
[17:35:02] Kai: Depending on the waveform values.
[17:35:28] Chaddock: or check the gradient before and after a value. If the gradient gose from positive to negative, or vice versa, then the gradinet is 0 at that point.
[17:35:45] Kai: To get d^2y/dx^2, you'd need to go through the data, subtracting the last value from the current, and store that subtraction.
[17:35:46] Kai: I think...
[17:35:55] Kai: And then test for zero on that.
[17:36:09] Kai: [17:35] Chaddock:

<<< or check the gradient before and after a value.That'd work.
[17:36:18] Kai: BUt then what if you have silence or something constant?
[17:36:25] Kai: The program might freak out
[17:36:40] Chaddock: For d2y/dx2, once you've calculated the gradient of your wave, calculate the gradient of that and do the same.
[17:36:43] Kai: Although, it'd just get to either end and stop.
[17:36:54] Kai: And tell you you were stupud for trying to encode silence.
[17:37:09] Ben Cartwright Cox: haha
[17:39:11] Kai: In fact yeah, it'd be quicker to find the gradient before looking for zeros
[17:39:47 | Edited 17:40:01] Kai: You might not need to find the gradient of the gradient though, just look for differences of zero without saving the entire function
[17:40:26] Ben Cartwright Cox: So I dun get it
[17:40:40] Ben Cartwright Cox: explain like I am not a maths guy what I need to do now
[17:40:55] Chaddock: I'll do a more detailed description.
[17:41:14] Kai: I could try to come up with an unoptimised algorithm
[17:42:29] Ben Cartwright Cox: Sure, In laymans terms ofc
[17:42:41 | Edited 17:42:42] Ben Cartwright Cox: I can implemnt it rather quickly
[17:44:06] Kai: I can't decide whether to process it section by section or make another array the length of the data
[17:44:35] Kai: Sod it, make an array the length of the data, fill it with the differences between adjacent values in the data,
[17:46:03] Ben Cartwright Cox: Well the only thing you should keep in mind is that you are basically dealing with int arrays that are 2048 ints at a time
[17:46:09] Ben Cartwright Cox: Since thats what I get them in
[17:46:42] Kai: Loop through the array, keeping a count of how many times it's (close to) zero whereabouts that happens and where the difference between adjacent array values is close to zero and positions, when the count equals 2 (I think, John?), so the regression magic, then reset the counts
[17:47:23] Kai: [17:46] Ben Cartwright Cox:

<<< Well the only thing you should keep in mind is that you are basically dealing with int arrays that are 2048 ints at a timeFor a start, make them bytes, we are compressing after all, and what you could do is:
[17:49:03] Kai: make an arbitrary length array (256 or something) loop through the original data, storing the differences between values in the array, check the array for zero, store location and increment count, when count = 2, go back through the array and store location and counts of where the difference between array values is zero.
[17:49:29] Kai: Then do regression, then reset counts and point to start of the array.
[17:52:16] Kai: Or loop through the data checking it for zero, store location and increment count, when count = 2, allocate an array the same length as what you just looped though
[17:52:28] Kai: Shall I just stop saying things?
[17:52:34] Ben Cartwright Cox: no do keep
[17:54:56] Kai: [17:32] Kai:

<<< You can easiliy enough dedecate a bit to mark the start of a sectionI'm talking nonsense.
[17:55:13] Ben Cartwright Cox: So if I get the gist of what you are saying
[17:55:16] Ben Cartwright Cox: Scan though
[17:55:19] Ben Cartwright Cox: til the grad = 0
[17:55:24] Ben Cartwright Cox: or near enough
[17:55:26] Ben Cartwright Cox: then do a poly encode
[17:55:29] Ben Cartwright Cox: then continue
[17:55:41] Ben Cartwright Cox: Rather than encoding in 16 / 8 sample blocks
[17:55:41] Kai: KInda
[17:55:47] Kai: Yeah.
[17:56:27] Kai: I'm probably wrong about where to do the encode.
[17:56:46] Kai: Ah, do you need to store the locations of d2y/dx2=0?
[17:57:02] Kai: I don't you do.
[17:57:15] Ben Cartwright Cox: I don't see why you would need it for decoding
[17:57:34] Kai: It's for generating the poly.
[17:57:46 | Edited 17:57:53] Kai: Judging by what John wrote, you'd only need the count
[17:58:00] Chaddock: I'm about to write how to find points where dy/dx = 0 and d2y/dx2 = 0
[17:58:20] Kai: So, what I did, but not fundementally broken.
[17:58:22] Ben Cartwright Cox: https://pbs.twimg.com/media/BiOSumBIgAAdLfT.jpg:large
[17:58:30] Ben Cartwright Cox: https://pbs.twimg.com/media/BiOSpZpIQAA59Ob.jpg:large
[18:00:12] Kai: Where do section boundaries lie?
[18:00:31] Kai: Where d2y/dx2=0 or where dy/dx=0?
[18:02:09] Kai: The first one.
[18:02:26] Ben Cartwright Cox: Why is VLC so magic
[18:02:30] Chaddock: Not necessarily.
[18:02:37] Kai: Hm?
[18:02:37] Ben Cartwright Cox: You can stream YT inside of VLC now
[18:02:46] Kai: Couldn;t you always?
[18:02:52] Chaddock: It is the middle d2y/dx2 between two dy/dx's
[18:02:53] Ben Cartwright Cox: as in, from the URL?
[18:02:56] Ben Cartwright Cox: Meaning you can also use VLC's live transcode inside VLC
[18:03:03] Ben Cartwright Cox: AKA, This YT URL into wav pls
[18:03:04] Ben Cartwright Cox: And it does it
[18:03:17] Kai: [18:03] Ben Cartwright Cox:

<<< as in, from the URL?Something else, I forget what
[18:03:35] Kai: Well, it was a URL, but not youtube.com's one.
[18:03:41] Kai: Well,
[18:03:46] Kai: I'll stop doing words.
[18:04:03] Kai: [18:03] Ben Cartwright Cox:

<<< AKA, This YT URL into wav plsHAPPY
[18:04:10] Kai: Must try.
[18:12:28] Ben Cartwright Cox: https://pbs.twimg.com/media/BiOWFgnIcAAyx4X.jpg:large
[18:12:35] Ben Cartwright Cox: 2small4me
[18:12:47] Ben Cartwright Cox: just download the imgur app on your iphone and upload though that
[18:13:03] Chaddock: huh?
[18:13:07] Chaddock: Hang on...
[18:13:45] Chaddock: twitter wants to compress the images for some reason.
[18:14:38] Ben Cartwright Cox: just download the imgur app on your iphone and upload though that
[18:16:07] Chaddock: http://imgur.com/a/sMnOG
[18:16:16] Ben Cartwright Cox: >This album is empty!
[18:16:17] Ben Cartwright Cox: How.
[18:16:21] Chaddock: FFS
[18:22:50] Chaddock: try now
[18:23:35] Ben Cartwright Cox: nop
[18:23:42] Chaddock: twitter.
[18:23:45] Ben Cartwright Cox: oh
[18:23:55] Ben Cartwright Cox: http://imgur.com/usUikbM
[18:24:01] Ben Cartwright Cox: Muuuuuuuuch better
[18:24:02 | Edited 18:24:04] Ben Cartwright Cox: I can read it
[18:27:09] Chaddock: do you need any of the others bigger?
[18:27:42] Chaddock: Oh, BTW, if you want to find d22y/dx2, just put your gradient array into the above algorithm.
[18:28:40] Chaddock: Excpet, you'll want to change th 3 condition, so that it will allow for points where d2y/dx2 = 0, and the gradient is both positive each side, or both negative each side.
[18:29:38] Ben Cartwright Cox: yeah I'ma work on that in asec
[18:29:41] Ben Cartwright Cox: Just about to eat dinner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant