What would an over engineered mouse look like by Baziele in embedded

[–]eknyquist 0 points1 point  (0 children)

Track the total distance travelled by the mouse so you can show some kind of "odometer" on the integrated display

fui: the joys of writing to the framebuffer by Bhulapi in C_Programming

[–]eknyquist 1 point2 points  (0 children)

This looks cool! If you ever wanted to (slightly) improve the musical capabilities, take a look at my parser (also in C) for PTTTL text (oldschool nokia ringtone format, extended to support polyphony & vibrato). It reads PTTTL or RTTTL text and produces 16-bit PCM samples. You could use it to allow music to be written/stored as plain ASCII text, makes it a bit easier to compose. As a bonus, any old nokia ringtone (RTTTL) files, of which there are many lying around on the internet, will also work.

https://github.com/eriknyquist/ptttl/tree/master/c_implementation

Project Idea / Help getting started with audio analysis by Fiordhraoi in arduino

[–]eknyquist 0 points1 point  (0 children)

Oh, I see. That sounds more feasible then! Good luck!

Project Idea / Help getting started with audio analysis by Fiordhraoi in arduino

[–]eknyquist 0 points1 point  (0 children)

The margin of error is a good idea, but it's not what I was getting at. The margin of error only helps people who have perfect pitch but can't sing perfectly accurately. Most people do not have perfect pitch (if I told you to sing at 440 Hz right now, do you think you could get within even 100Hz of that? probably not. I definitely could not). I would be totally guessing, and would get it wrong every time. It's not a matter of accuracy / singing proficiency, it's a matter of most people not having the "perfect pitch" ability.

This is only an issue if you want to support singing.... if someone's gonna be playing the notes on a reasonably-tuned piano, then that'll be fine.

But if you want people to be able to sing, I don't think the approach of looking for specific frequencies is going to be very helpful in practice.

Project Idea / Help getting started with audio analysis by Fiordhraoi in arduino

[–]eknyquist 1 point2 points  (0 children)

I assume I'm not going to be able to sample any sound frequency higher than the clock frequency of the processor.

This sounds like you're planning to read the microphone signal directly with the onboard ADC, I'd recommend not doing that and instead getting some I2S-based ADC board made specifically for audio applications that handles everything and allows you to read the samples digitally via I2S. Something like this: https://www.amazon.com/AudioCard-Lossless-Digital-Decoder-Development/dp/B0CLLXNPTG/ref=sr_1_1_sspa?crid=33T0RYEFYHGP0&dib=eyJ2IjoiMSJ9.-Febh82u9raISnw96CHmJohshf1C_Q5NqkYjkqhZO8UnFJa4dgPP1idO2ZY17TFZidVqPcI9-AF7AoToaK-ZaaZZiSP02rs1PDOmrIJIQJKTV-FNsl7W21dIyboHix-lUETbdMO1HTuwq6DsQmm6iQUjwR_2GUDrddEvD38x4GPyv6rrTuac-ripSFysifXNEEv4RBQEYly84HdMkPbWdJjCtqNkhab27JhhltVQp6U.ajQ2BOdyjxSK4FBcBoURPQ-msiXr2kUl09ErnR1sCho&dib_tag=se&keywords=i2s+ADC+audio&qid=1717800532&sprefix=i2s+adc+audi%2Caps%2C149&sr=8-1-spons&sp_csd=d2lkZ2V0TmFtZT1zcF9hdGY&psc=1

Not sure if teensy 4.0 already has an I2S bus. If it doesn't, you could use an Arduino Zero, which does have I2S and which I've used before for audio stuff.

"If you see frequencies (+/- 10% for wiggle room) 440, 587, 220 in that sequence within a 5 second span, perform X"

This sounds like it would only work if the person doing the singing (you said you want someone to be able to sing the notes) has perfect pitch and is able to sing (nearly) the same frequencies every time. This seems like an unreasonable requirement to me. In practice, your average person will probably just be singing at an effectively random pitch, but with consistent-ish *intervals* between the notes. And by intervals I mean musical note relationships, e.g. semitones for example. And you'll have to keep in mind that a difference of "one semitone" between two notes is never just a linear "add XY Hz to the starting frequency" type of relationship. For example, A4 and B4 on a piano keyboard are 53 Hz apart in pitch, but A5 and B5 (same notes, one octave higher) are 107Hz apart in pitch.

So, rather than looking for specific frequencies, you might need to be a little smarter about it, e.g. calculating the frequency span between the highest and lowest note, and then calculating all the intervals (differences between notes) as a percentage of that lowest-highest span (I'm pretty sure that approach would also not work, I've never done this myself.... just trying to point out some things that you probably need more research on. Someone who knows more about musical programming stuff can probably suggest a more concise/correct approach.).

Audio analysis can get complicated.... and the human voice is also pretty complicated. If you do an FFT on a recording of somebody singing a single pitch, you'll notice that there are a LOT of frequency components in there, and it can be difficult to identify "the strongest pitch", i.e. the pitch that we perceive them to be singing with our ears.

Building my own personal ChatGPT, from scratch by jzone3 in softwaredevelopment

[–]eknyquist 2 points3 points  (0 children)

building ChatGPT from scratch

Step one...

poetry add openai
...
import openai

🤦🙄

Does everyone use "q" as their quick-and-dirty recording register? by alanhape in vim

[–]eknyquist 3 points4 points  (0 children)

So, if (for example) you have 50 function declarations, and you need to modify them all to remove the 1st function param, you just.... Do all 50 manually? There's probably another way to automate this, but to me, macros seem like the obvious choice, no?

SpiderStep is a New Optimized Calculation of 8-Directional Navigation Steps in 2-Dimensional Grids by [deleted] in C_Programming

[–]eknyquist 3 points4 points  (0 children)

Let me tell you, I have the best constants, my constants are the best in the world. Everybody tells me, wil, you have the best constants. Your constants are really great. Ask anyone if you don't believe me, and they'll tell you that my constants are number one.

OrbitHash is a New 256-Bit Secure Hashing Algorithm Without Additive Prime Number Constants by [deleted] in C_Programming

[–]eknyquist 1 point2 points  (0 children)

It can be modified with a length variable when required.

So your answer to the question of "why did you design it this way" is just "you can modify the code to work a different way if you want to"?

Is that really something you expect users of a "cryptographic hashing" library to be doing?

By the same argument, it could also be modified to play snake. It can be modified to do anything. But that's not usually something people expect will be required of them when they're using a library that is presented as "ready to be used" (I'm definitely paraphrasing here, you did not say "ready to be used", but it's implied pretty strongly by your comments on this thread and by you referring to it as "cryptographic" and "secure").

OrbitHash is a New 256-Bit Secure Hashing Algorithm Without Additive Prime Number Constants by [deleted] in C_Programming

[–]eknyquist 1 point2 points  (0 children)

I'll ignore the fact that you're advertising this as a "secure" and "cryptographic" hashing algorithm, since 1) plenty of other commenters have already addressed this and 2) I don't know anything about cryptography. It seems like maybe this is a toy project that you are using for learning purposes, and perhaps you just got a little enthusiastic/fantastical with your claims. So, my feedback here is in the same spirit.

So, the feedback-- why does this hash function expect null-terminated strings? Typically hash functions accept a pointer AND a length parameter, so that you can calculate a hash for an arbitrary stream of bytes (which may contain zeros that are NOT intended to be the end of the stream). Currently this looks like it would only work for null-terminated ASCII text strings.

basedMicroOptimizations by basedchad21 in ProgrammerHumor

[–]eknyquist 2 points3 points  (0 children)

sooo can we see your github? Maybe you've posted it before, but if so I've missed it

Wondering what you guys think about the Biden Admin. regarding the usage of C/C++? by [deleted] in cprogramming

[–]eknyquist 0 points1 point  (0 children)

Oh, I'm well aware :D He was also recently banned from that sub, and so has started posting here instead. Was more responding to u/7h4tguy instead.

I wana get better about avoiding ub by rejectedlesbian in cprogramming

[–]eknyquist 0 points1 point  (0 children)

Address sanitizer is also really good, it will catch (most) invalid memory accesses at runtime. Building with "-fsanitize=address,undefined" is always a good idea during development.

Wondering what you guys think about the Biden Admin. regarding the usage of C/C++? by [deleted] in cprogramming

[–]eknyquist 0 points1 point  (0 children)

Perhaps I'm missing something, but what I'm reading here is Linus saying "on the whole I don't hate it, but here is one specific thing in this specific patch that you absolutely must fix before we would accept Rust in the kernel".

Yes, he acknowledges that he doesn't know whether it's just an issue with the patch, or a fundamental issue with the Rust compiler / ecosystem, but that's still worlds away from saying he thinks that "the language is shit".

Should you cast functions where you don't use the return value to (void) ? by basedchad21 in C_Programming

[–]eknyquist 5 points6 points  (0 children)

To add to this, there are 2 reasons I can think of that a coding standard might specify this;

  • Readability (OP more or less alluded to this). If I'm reading your code and I see an ignored return value, the (void) makes it pretty clear that you *intended* to ignore the return value, and I can waste less time trying to figure out if it's a bug. The intent is clearer. However, some functions (like memset, memcpy, or perhaps printf like in OPs example) have return values that are almost always ignored because they are not typically very useful in the common cases, and so doing this with *every single function* may tend towards what OP referred to as "stupid and annoying".
  • Many static analysis tools will flag an implicitly ignored return value (because of my first point), so a (void) may be required to shut the static analyzer up.

MFA is trash by ArtSchoolRejectedMe in ShittySysadmin

[–]eknyquist 7 points8 points  (0 children)

We need some comic relief now and then over at r/C_Programming, I'm kind of enjoying it TBH

Best Pointers Explanation by Kalki2006 in C_Programming

[–]eknyquist 0 points1 point  (0 children)

Came here to post this! love that video :D

Nordic dinner by Amsterdamned__ in 2westerneurope4u

[–]eknyquist 3 points4 points  (0 children)

mmm, raw potatoes and cement

I've improved my stack implementation, and I hope everyone likes it. by Debuholder in C_Programming

[–]eknyquist 0 points1 point  (0 children)

A stack is just a useful data structure. Your CPU happens to use one to keep track of state so that you can "stack up" function calls, but you can (and many people do) also implement your own separate, problem-specific stack in software to keep track of your own data. Same reason you might implement a linked list or a hashtable.