Hacker News new | past | comments | ask | show | jobs | submit login
I made a guitar tuner app using Flutter and Rust (justune.eu)
208 points by zduny on Oct 10, 2022 | hide | past | favorite | 146 comments



The app looks great, but since no source code is provided knowing that it's made with Flutter and Rust isn't really of much use for anyone (esp. for learning purposes).

For anyone interested, I found a nice open source tuner for Android https://github.com/thetwom/Tuner


Evil plan:

1. Create closed-source app in some boring language

2. Promote on hacker news as "written in Rust"


3. Rust is a boring language.

4. Recurse!


Agreed. Without source code, this is just Yet Another Guitar Tuner App(tm) this time with Magic Rust Pixie Dust(tm) (take our word for it).

If they release source code, I'll toss them money. Until then, pass.


"toss them money" ? i'm confused. Also, if you view-source you can see some boilerplate that strongly suggests it's flutter


This is the tuner I use! It works great, definetely recommend it.


+1, just as effective as in other phone tuner without all the obnoxious ads.


There are two Drop D tunings listed and one is actually Drop C. There is no Drop D♭, you call it Drop C♯ which while it's technically the same set of tones, it's now how guitar players think of it. You have the same issue with E♭ Standard. Each of your notes in these tunings are listed as sharps instead of flats, which is not how guitar players think of the notes in these tunings.

Also, you might want to consider polyphonic tuning. That's what would set you apart from everybody else. I bought a TC Electronic PolyTune earlier this year and it's been a game changer. It's much faster and easier to get tuned


Interesting you mention guitarists thinking in terms of flats. Is that rooted in music theory, preference/convention, or something else?

A sibling common mentions "c#, g#, c#, f, g#, c#" which is exactly how I would think of it. I'd guess that without a key signature to reference it doesn't really matter, but I'm a theory novice so curious about this.


I’m self taught, and I tend to think of flats because I tend to downtune. I think others choose the flat or sharp based on their desired key. That doesn’t help me describing a tuning if I’m playing out of the tuning’s assumed key! I have adopted one set of tunings which requires bringing the second string higher than the first, which I usually dedicate to a guitar with the strings swapped so I don’t break them all the time. (Adapted from very closely watching performances by Kelli Rudick if you’re curious.) I always describe the 2nd string tuning with sharps unless I have a good reason not to.

None of this is meant as advice, it’s just how I reason about using the instrument myself in ways it wasn’t necessarily intended.


I assume it's because tuning a string up can break it, while tuning it down is harmless.


I would guess that it's to do with the fact that musicians generally use the key with fewer sharps/flats. E.g., Bb major (2 flats) instead of A# major (5 sharps). This also follows what's on the circle of fifths, where major keys clockwise from C use sharps, and vice versa.

In the case of drop Db, I would also guess that people just think of it as "slightly lower than drop D", hence just adding a flat symbol.


Nit pick: A# major would be 10 sharps, at least written following the usual convention of each note letter being used exactly once: A# B# C## D# E# F## G##.


What is 2 but 1 plus 1? The key of B flat is easier to read.

Disregarding how it'd be read, I suppose you could theoretically get into keys like G-triple-sharp or F-quadruple-flat -- but that's just overcomplicating things, isn't it?


I really don't know why that's the convention. I always assumed it was due to the minor scale/modes having so many flats. The only mode with a sharp is Lydian - and that's a single sharp! Even the major mode Mixolydian has a flat! Natural minor has 3 flats.


I'm interested in the algorithm for that, but it looks like for PolyTune, they just say "patented 'MonyPoly' algorithm."

So that's out. I wonder what other research has been done into detecting multiple notes at once?


Each string has it's fundamental frequency and harmonics. Some of them coincide or are very close in frequency, but some are unique to one string so can be picked out and their frequency measured with a FFT of sufficient resolution and used to indicate the tuning of the string it must be a harmonic of.

(Polytune is more robust than just doing this and does work really well, but if the guitar is really out of tune the method falls apart and you have to use its one-string-at-a-time mode)


Fourier Transform, identify the fundamentals by loudness and/or presence of harmonics?


In general polyphonic pitch detection is a much harder problem to solve than monophonic. I guess focussing on guitar tuning only rather than trying to transcribe a whole song makes the problem a bit simpler but still is probably a lot more challenging than handling one note a time. Cool feature though, I had never thought of a polyphonic tuner!


My Snark died and I was about to order another one when I saw the TC Electronic PolyTune. I splurged and bought it. I love it!


Can one set the A to 432Hz?


Why is it good? Interested


Because you can see the tuning of all the strings at once. You strum and they all show up. Then you can see which ones are more out of tune than others and tune them together. Prevents problems where changing the tuning (tension) of one string throws another string out of tune. I call it "global tuning." It gives you precise tuning extremely fast.


Does the tuning of one string affect the others on guitars with hard tails, or is this mostly a tremolo induced issue?


Yes, for hard-tails. Neck construction doesn't matter either. I notice it on both bolt-on and neck-through instruments. My method is to tune the highest strings first and work down to the lowest since that seems to minimize this effect.


I believe the issue is due to small changes in the overall tension on the instrument caused by changing one string’s tension.


Ok. Sold!!! That is awesome.


As an alternate tuning person I’d love a simple ‘this is the note you are playing’ I hate having to pick the tuning as I just wanna know a c#, g#, c#, f, g#, c#

Please :)


Snarks will do that automatically.


Agree!


It's available free (and no ads) for desktop browsers and as a $1 Android app (on mobile needs to be an app for performance reasons and I believe it's a fair price).


While $1 is certainly far less than the value this app provides, it’s going to be a hard sell when there are several free apps which do the same thing.


Yes, but to be fair it's awfully hard to find a free app that does the same without bloat due to any kind of ads. I'm going to buy this app just because of frustration due to that.


Sometimes, But a similar "utility" (shameless promotion here) I've made a free open source metronome. No ads and cross-platform.

https://tick.talaviram.com

So if someone like me had incentive for free metronome. I'm pretty sure there are also tuners out there.

Still, 1$ to support an app is really legitimate and sometimes gives more incentives for the developer to maintain it or add features.


There are several such apps on f-droid.


F-droid often has nice apps, but too often, they are just not good enough for what I want or need[1]. In that case, I'll gladly pay on the play-store because the paid version is nearly always (but certainly not guaranteed to) have less or no trackers ads, and malware included. The free apps far too often do.

I use https://exodus-privacy.eu.org/ to check for trackers, ads and "malware".

[1] Far too often, the apps there are "OK, but...", clearly the work of a someone building a quick "works for me" or someone learning how to build apps. For some tasks, "just OK" is good enough. More often it just isn't.


I will pay anywhere from $1 to $5 to eliminate ads, so this is a good value, considering the free apps almost all have ads, if I recall. Or are provided by one of the larger guitar companies and promote their subscription/learning platforms?

I find the idea that $1 is a "hard sell" laughable, but unfortunately for software devs that is the world we find ourselves in when trying to monetize an idea.


Same. If I see a free app and a $1 app that does the same thing, I'll probably go for the $1 app.


Well, there are also already at least dozen free ones that allow to buy ad-less versions

> I find the idea that $1 is a "hard sell" laughable, but unfortunately for software devs that is the world we find ourselves in when trying to monetize an idea.

and it's hard sell because you can just pick any of them, test to your liking and pay for one after using it.


The intersection of "free", "no ads", and "works right" is often pretty bad. This at least has the web interface where you can see roughly what you would be getting.


I agree. Although this might be more about covering development costs than making OP money.

An important distinction so many entrepreneurs fail to make. Don't enter a saturated market without anything new on the table if you intend to make money.

The problem with this particular market is that musicians can mostly tune by ear. Most will have a dedicated tuner next to their instrument and worst of all these apps don't perform as well for a variety of reasons not least of all that the response of the device might be off.


Musicians can tune by ear, but the vast majority of people who play guitar on a daily basis are novices or beginners and they all use tuners or tuner apps.


Even if tuning by ear, when you play with a band or especially are recording, it would be very silly to trust your ear alone because recording hours of takes in an expensive recording studio with many other people's time in a slightly out of tune key would be very disrespectful and wasteful.

Most musicians can tune "relatively" okay, but do not have the ability to tune "absolutely" (perfect pitch).

Here is an example of perfect/absolute pitch that very few musicians have. This is the skill one would need to be able to not use a tuner at all > https://www.youtube.com/watch?v=dw3-k9 (Jimmy Kimmel Puts Charlie Puth’s Perfect Pitch to the Test).


For sure. We always tuned by plugging into tuners when I played in a band. You might get it to closer than completely out of tune by ear, but when you're in close quarters and there's people talking or playing their music, you just plug in and get to the green light.


Even if you can tune by ear, it can be faster to use a tuner, especially in a noisy environment. Also, if you listen to harmonics when tuning a guitar by ear, you'll get something like just intonation instead of the equal temperament tuning that you would get with typical tuner apps.


Or if you’re paying, just spend the extra few books (it’s $10) and get Petersen Strobosoft which is the absolute gold standard.


Or skip the idea that your phone makes a good tuner, spend $35, and get the TC Electronic Unitune. It's by far the best tuner I've used so far, and it's small enough you can just throw it into your guitar case. (Or leave it permanently attached)

Plus, it's much less fiddly to handle than balancing a phone and a guitar :)

Ultimately, it's a matter of taste, and what you use them for.


Lots of things to tune that aren't electric guitars ;)


The TC works just fine w/ any number of string instruments that aren't guitars or electric :)


Now try to tune a woodwind with one :)


Not available on Android, far as I can see.


Ok.


I also will need to buy a guitar to use this app, so if anything you should be paying me to use it


Is the app the same as the desktop version feature wise?


The movement is really choppy on my iPhone 13 Pro. Did you use requestAnimationFrame for the tuning movement? & CSS animations for switching instruments? Kinda just wondering how the performance could be so bad. Reminds me of PhoneGap circa 2013


I can confirm. It is extremely choppy and resource hungry for what it does. Since they use Flutter, the UI is rendered using 119 canvas elements. The same thing could be implemented using the web platform (no flutter and no rust) with better results.


I was thinking the same thing- I've seen many mobile performant, web based tuners before, it's a very common personal project. If the intention was to make a web based tuner from the start, Flutter and Rust was a big step down from just using HTML and JS.

I know the trend on HN is to upvote any project with Rust in the title, and to hate on native JS, but projects like this that have to use a bunch of tooling to eventually compile down to JS would have almost always been better just using JS in the first place IMO.


Flutter is not web-based. It's all custom.


That is true (that Flutter builds natively on all platforms it supports, and controls every pixel on the screen, unlike React Native and similar).

But I suspect these people were trying the web version of this (pretty neat, IMO) app.

Flutter does build for the web but then it does (of course) use web technologies to deliver the UI. To get the native experience on iOS, you'd have to download the iOS version from the App Store or something like that.


As an undergrad I made a guitar tuner using a PIC32 microcontroller to do time-series correlation to figure out the frequency (FFT was too slow for real-time) and a state machine embodied in a stratix FPGA to control a stepper motor to turn the pegs. A different era of “mobile app” I guess.


Correlation is calculated using FFTs, so wouldn't that be just as slow?


Computations can be reduced if you only care about frequencies near 6 particular ones (and maybe some harmonics).


You'd get shit tuner if you do that. Ain't nobody got time to define scales on a fucking tuner


There's only 12 per octave, way fewer than doing FFT for all frequencies in Hz steps.


I would love to see the source code, or at least a simplified version. Audio input in rust and rust talking with flutter on mobile device. Such a cool project.


I don't think it's related, but a post from someone showing a simplified version of the same idea (pitch detection with WASM/Rust), with detail and source: https://www.toptal.com/webassembly/webassembly-rust-tutorial...


Well, all the Rust crates I've mentioned in other comment have comprehensive examples attached, so it's just a matter of connecting their functionality together :)


Looks very nice, would you tell us a little bit about what you used to build this? I am just getting started with Rust and it would be cool to hear what approach you went and what you would recommend when starting today.


Flutter for the UI. Rust for the listening, and pitch detecting backend. Connected the former with the latter using flutter_rust_bridge.

More details on Rust backend:

For listening (getting audio signal from microphone) I used:

- Android: https://crates.io/crates/oboe

- native desktop/iOS (not currently released): https://crates.io/crates/clap

- Web: https://crates.io/crates/web-sys (so basically JS Web Audio API called from Rust compiled to WASM).

For pitch detection:

- https://crates.io/crates/pitch-detection


> - native desktop/iOS (not currently released): https://crates.io/crates/clap

I hope you didn't use a command line parser to stream audio...


I meant https://github.com/RustAudio/cpal (should've checked).


Haha, no worries :) "clap" does indeed sound audio-related, and "clap" is only one transposition from "cpal"!


Heh, I always get those two crates names confused, even now, rereading comments I again thought it was "clap" and not "cpal" (because "clap" like in "clapping").


"clap" IS actually audio related too https://github.com/free-audio/clap :)


>Flutter for the UI. Rust for the listening, and pitch detecting backend. Connected the former with the latter using flutter_rust_bridge.

It's good to see that there is a active project to help with making Android apps using rust.


Why not just dart?


Dart being a GC'd runtime makes it quite hard to use for low latency audio applications, probably not as critical for audio input as output, but still potential issue, for more details see: https://github.com/dart-lang/sdk/issues/46943


Then why bother with Flutter at all?


It's amazing for UI (and portable).

Rust - not so much (or more like not at all) at the moment.


And has a GC running all the time, including when the called Rust code is executing, making it pointless to avoid using Dart in first place.


Awesome, thanks!


This might have an obvious answer for the more experienced here, but (potentially stupid question) why didn't you use dart for this?

Nothing against rust, just interested is all considering the dart/flutter relationship.


Performance reasons, also wanted it to work on the web (Flutter web support is fairly recent, and dart/flutter libraries don't automatically work on the web, they have to support the platform).


Thanks. Is dart performance that bad? I thought it compiled to machine code if needed.

With the web support I was hoping the since dart can be transpiled to JS Flutter might do something similar. I'll have to look into this, I'm learning Dart due to its ability to run on most platforms.


It's hard to say with performance (you need to measure), but I'll point out that for the web, Dart is compiled to JavaScript.

Performance is pretty good, but as with JavaScript performance, there are performance cliffs depending on how well V8, SpiderMonkey, or JavaScriptCore is able to optimize the code. An audio worklet is pretty standalone and compute intensive, so it seems like a good place to use WebAssembly.


It's not great. Especially on the web.


Speaking only for myself, I'm considering Flutter + Rust because I want to write everything in Rust, but there aren't great GUI options for Rust atm. I've heard good things about the rust<->dart bridge so it seems like a reasonable compromise, esp. given the Dart code to write Flutter UIs seems fairly declarative. Hoping to keep most of the logic in Rust and just the view in Flutter/Dart.



yes


[flagged]


What is that anger about Rust on internet forums about?

I started learning Rust because it's a language with interesting characteristics and welcoming documentation.

Only then I've discovered it's apparently "controversial" for some reason...


Members of the rust community were often accused of being overly-enthusiastic in recommending that things be rewritten in rust, so much to the point it more or less became a meme unto itself.

Now, visceral anti-rust gut reactions are more commonplace than inappropriate suggestions to use rust are. Even that is petering out, though.


Dammit. Was writing a similar yet a bit more extensive elaboration on my phone, but accidentally refreshed the page a-a-and... it's gone :') Truly a RRRRREEEEEEEEEEEEEEE moment.

Basically, 'this ^', but wanted to add that the post was a lighthearted jab and a comical insinuation. Which, by the way, according to the little rollercoaster of upvotes and downvotes, seem to have raised a micro controversy of it's own. Which adds another layer of comedy to the entire situation.

A-A-ANYWAY. Since I was a bit upsetting, adding a (hopefully) evening out, on-topic suggestion.

For tuning my guitars, I often use gStrings app [0]. For some reason it's much better at 'catching' freqencies than the alternatives. Can't recall all the names, but I've tried most of the popular ones (such as Guitar Tuna, the Fender's one, etc). Might wanna check it out and see if there are some tricks to borrow :)

[0]: https://play.google.com/store/apps/details?id=org.cohortor.g...


I'm looking for JavaScript library that would allow me to build a hobbyist autoharp tuner. I can program the UI, but need a note generator library. It just needs one API function or equivalent: soundNote(noteNum, duration); Note-number is the MIDI note number, and duration is the duration of the note in micro-seconds. (It can be in "beats" when the beat unit is defined via another function.)


Purchased for Android, love Flutter and been trying to learn guitar off/on, so this could be helpful.

Question re: web (where I have not been impressed with Flutter as a platform) - I just get "Failed to start listening thread." I tried both Firefox and Chrome, latest versions.

Side note: Also noticed I can't highlight/copy the text (common usability/accessibility issue with Flutter Web. I believe it's not that hard to allow?)


You may already be aware, but having a small clip-on digital hardware tuner you can use anywhere without involving a phone is a life upgrade if you're playing guitar on a regular basis.

Of course, this is a cool project for more insight into the technologies involved regardless.


Yah, I keep meaning to get one of those, just haven't remembered to do it. And I'm super bad at guitar, so probably not playing anywhere outside of my basement for a while :P


The developer is supposed to use a SelectableText widget: https://api.flutter.dev/flutter/material/SelectableText-clas...


I don't know if it is allowed here:

Please reply if you would be interested in free promo codes for the Android app, I will post some.


20 promo codes for the Android app:

[all codes have been redeemed]


I redeemed 4PLTCBMWVANG2DSDK5L6J0U.

Thank you!


When I click through, all I get is a black screen that says "Failed to start listening thread."



Android or Web?

If web - well, it sadly requires modern browser on relatively modern hardware - it has some performance problems currently in browsers, I'm not happy about that fact, I am considering improving it if the app catches enough interest.

If Android - please consider returning the app and getting your money back as long as you still can - I'm afraid I won't be able to solve it in quick fashion.


Does not work on my Galaxy Note 9 unfortunately(I granted the recording permission, but it can't pick up any sound). However, it works fine on desktop Firefox. I think a try before you buy option would be useful.


This is pretty handy, though my usual tuning method is to play a pure tone and match to that. Makes getting right there so much easier when you hear the warbling between guitar and tone stop.


This is very cool! Is there a way to contribute or something to have support for ukulele ? I'm just starting to learn the uke and this could be very useful.


There's a Ukulele switch at the bottom left of the window.


Oh man, somehow I missed this on desktop. Thanks a lot!


What algorithm are you using? I've been tempted to write a tuner using autocorrelation, because in my experience it picks up pitch wonderfully.


Look at this crate: https://crates.io/crates/pitch-detection

It has documentation attached mentioning pitch detection algorithms it implements.


This is surprisingly useful. Thanks!

I used an iPhone app with similar interface but couldn't find one that's as intuitive on web until this one.


Do you have any plans on open sourcing the code?


Not at the moment. Sorry.

I'm planning to create a simpler free version of the app for the sake of cross-promotion, I may open source that one (but I can't make any promises currently, both regarding creating the actual app and open sourcing it).


How do you scroll the list on the left? It doesn't have any scroll bar or scroll buttons that I can see.


With the mouse wheel/trackpad. Flutter Web doesn't actually generate proper DOM, instead it renders things (mostly) from scratch, hence no scroll bars.


So if you don't have a scroll wheel the interface is broken.


Yes, AFAIK. Flutter web is pretty terrible, especially for any form of accessibility


Thanks for mentioning the problem. I haven't noticed it using a laptop and trackpad.


Assuming you're using A440. I do not see a way to change it to my preferred reference frequency A432.


I'm considering adding that feature in future versions depending on interest.


Nice work, going to put this to use tonight!

P.S.: you've got a customer if you plan to port this to iOS.


What does Rust add to the whole user experience that couldn't be done in Dart?


Can you add Ukulele to the drop down? There are only a few common tunings.


Cool! What's the deal with `DADGAd` being `D#ADGA#D#`?


Ben Howard and Nick Drake tunings. That’s funny!


And wow! He really does use it a lot!!!!


Enjoying humming the tune to make it hit haha


Are you going to release it on Windows 11?


So how do you tune 7 string guitars? :)


Maybe in future version :)


Nice!

We’re you inspired by the GuitarTuna iPhone app?


This looks _very_ GuitarTuna. I've not come across another app which uses the (IMHO very effective) vertical scrolling pitch visualisation.

This is great though OP. It's the best browser-based tuner I've ever used. I really hope you don't get sued.


Yes, I did the app mostly for myself as I was getting disappointed with them adding too many unnecessary (IMO) features to it.


Beautiful!

Can I request banjo and chromatic modes?


Super cool! Also, love the UI!


Hello Rust Music World!


iStrobosoft is the best tuning app. No contest.


the idea of a 'virtual' strobe tuner is a curious one - a strobe tuner being such a material thing. I'm not contesting that Peterson's is the best, but the 'strobe' aspect of it has to be marketing guff, doesn't it?


There was one strobe-like tuner for Android years ago that seemed to be something other than a visual representation of a standard digital tuner.

My understanding of the way it worked is that it took the waveform over some set N/frequency time, converted it to a 1D horizontal line of black→white pixels, and then stacked subsequent lines to create a 2D image, with new lines being added at the top and moving down. In tune (or a multiple of the root frequency for the image), you'd see a series of vertical black and white bars; out of tune, these bars would slant to the left or right, and move over time.

This method was actually somewhat like a strobe tuner in mechanism, replacing the persistence-of-vision appearance of the bars moving with a spatial representation of the audio waveform moving in comparison to the reference frequency. Presumably, this could also have been done without the stacked 2D representation, but that doesn't seem to be what apps like iStroboSoft do, as the bars are far too clean and even. While the app didn't do it, harmonic partials could have been added by having multiple simultaneous 2D images, each with a different reference frequency.

Unfortunately, the app and its developer disappeared years ago, and while I might still have the apk somewhere. I haven't seen anything like it since.


I now recall that this was Pitchlab / Pitchlab Pro. The app still seems to work on Android 11, but isn't available through Google.

The last version's release notes, combined with the subsequent discontinuation and disappearance, suggest that there may have been patent problems that led to its demise.


It is. It’s just a pity they haven’t updated it in a while.


Is there an Android/web version?


No. Although there is a 1.0 version APK floating around and that's what I use. It's pretty great.


Really nice


Very cool. Looks great.


Cool, good job! :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: