Self contained (violin like) instrument; Daisy Seed suitable?

Hi,

New to Daisy Seed, trying to wrap my head around what it can do.

For a while now I’ve been wanting to build a violin like instrument, using ‘softpot’ linear potentiometers to input to a processor, which outputs the appropriate note from an onboard speaker, while recording the resultant sounds as mp3 and (maybe) even as a midi file using pitch shift information for the inevitable glissando.

I 'm also hoping to add the ability to whistle notes into an onboard microphone (plus maybe recording this as mp3 and midi) and have those notes appear as lit leds at the appropriate point(s) on the fingerboard, as an aid to learning to play by ear, etc.

I’ve managed to get the whistling part to work before, using VB code that read the pitch from a program running on the PC, passing values to a Picaxe microprocessor outputting to a strip of leds via shift registers. It was a bit of a hack, but that was all I could do at the time. I’ve also played around with pitch recognition in Python on the PC; it was fairly easy, accuracy was good, but it was glitchy, with unacceptable latency.

The difficult part would be doing all this on a portable, lightweight device, with imperceptible latency, and having an onboard library of sounds to output including a realistic violin sound. It’s not supposed to a concert instrument, just a fun toy/teaching aid. The plan further along is to add a ‘bow’ to activate some kind of sensors to input velocity and some effects, like playing the bow nearer the bridge than usual, etc.

I have an Arduino mega 2560 to play with, but I have a feeling the Daisy Seed would be more suitable?

Any thoughts would be helpful, thanks!

The 2560 has no where near enough power to do what you want. The daisy may have - the unknown to me is mp3 encoding. I’ve written a mp3/flac/wav playback system on the Daisy and it’s around 4%-10% decode time from a sdio sd card (using the wonderful dr_libs GitHub - mackron/dr_libs: Audio decoding libraries for C/C++, each in a single source file.). I’m guessing that mp3 encoding will use a lot more cpu time than decoding. The other parts you’re talking about - freq analysis - daisy can chew thru FFT’s with ease - and any additional analysis required on top of that - usually some kind of overlapped spectrogram analysis e.t.c. 16mhz 2560 - u’d have to be a lord code guru :slight_smile: to get that running smoothly.

I’m definitely no Lord Code Guru! More like undersecretary to Lord HackBadly; so Daisy Seed it is then.

The mp3 recording is probably the least necessary part; I’d just need something that would allow me to record the value of the fundamental frequencies of both the input whistle and output violin sound from each active ‘string’ against time, so maybe just a .CSV file or 3 would do.

Writing something to read that and playback should be doable for a Daisy Seed? Although in the long run, real time or at least decently fast pitch to midi would be best, probably treating each ‘string’ as a separate instrument.

[quote=“Moorea21, post:3, topic:5779”]
I’m definitely no Lord Code Guru! More like undersecretary to Lord HackBadly; so Daisy Seed it is then.
[/quote] I claim “the sloppiest coder in the world title” to outdo your “HackBadly” title :slight_smile:

that Dr_libs library has a wav writer - not used it but going on the rest of the library should be simple enough. The freq analysis - you said you’ve already done. I’ve tested FFT performance on the DS and it’s fine - got a 60fps spec analyzer running on a IPS lcd - no problem at all - plenty of power for that kind of stuff. I did some simple math on how big a convolver you could do on the DS it was around 30secs or more? (not applicable to what you want - but gives a idea of the DSP power). If you want to write files - make sure you get a SDIO sd card interface for the DS - and not a SPI sd card interface (SDIO is waaay faster!). I’d be interested to hear how you’ve done the mic whistle analysis - just curious. If I was doing that kind of thing - I would use 2 overlapped FFT’s calc the bin phase differences and get a list of exact frequencies in the signal - and pick the largest.

Hope that helps !

Okay, is that an option at the point of purchase, or something I should look for on Aliexpress?

The FFT code was AI generated; complex numbers and actually reading documentation for numpy/sounddesign wasn’t something I was prepared to do for a proof of concept job, but it lets me see the principles at work, and understand enough to be able to tweak the code in ways that aren’t completely random. I’ll post it here if you like.

As for the whistle analysis, it turns out that my whistling is a fairly ‘clean’ signal, very few/weak overtones, in a range of about 500 to 2600 Hz, so apply a Butterworth filter to the input for highpass to reduce noise, which is a function available in Python soundDevice package, then the FFT function records amplitude and phase for each frequency into an array, splits it into ‘bins’ I believe they are called, reads amplitude for each bin, chooses the largest and labels that as the fundamental frequency.

That’s my understanding of it anyway. I ought to play with reducing the sample rate, and replace highpass with bandpass, so there’s less data to crunch; it would run faster and be less glitchy, but I probably won’t bother, as it was just to get my head around how it works a bit. It’s probably far from optimal in many ways, but its outputted data corresponded well to that seen on Audacity’s spectrum plots, which was a relief.

the SDIO card reader is something you have to buy - I got mine on Amazon a while back: https://www.amazon.co.uk/gp/product/B08FB3GC34

that connects directly to the SDIO pins on the DS - and works nice and fast! You can see all 4 data pins are connected and have resistors (I think they are resistors - not a electronics bod!). A SPI reader will only have 1 data pin and be a lot slower!

here’s a great tutorial on overlapped FFTs for freq analysis (don’t use this for pitch shifting tho - it’s useless - phase issues - but it is a great tutorial non the less). If you use this - you’re no longer limited to the width of the freq bins - you get the exact note frequencies. (Pitch Shifting Using The Fourier Transform | Stephan Bernsee's Blog)

Good article, although anything maths related makes my brain hurt, so I skipped it and read the conclusion to that section. Looks like wndowing isn’t something I’ll need, I didn’t know about overlapping samples though, so that’s another variable then… although my code didn’t explicitly mention anything like overlap, and gave good results, if it ever doesn’t, I’ll know that’s an optional strategy. Unless of course it does that ‘under the hood’ in numpy.

Will this do? I may even have one somewhere

Or this, not 3V:

That first one looks just fine ( Adafruit) - the second (ebay) one has no resistors e.t.c.

I’ve just noticed that Daisy Seed seems to have 3.3V o/p on pins 21 and 38, labelled analogue and digital respectively. Does this mean I can power the 3V adafruit SPIO board from one of those?

Of course - that’s how u power that card reader board.

And there was me thinking I’d need a dc to dc converter powered off the usb and set to 3V…

You generally power all ur devices (lcds e.t.c) from the MCU’s 3v digital pin. As long as your combined devices don’t allow thru more current than the supply is rated for - it’s what it is designed for. Can’t remember DS current limit on the 3.3v - 80ma? 100ma? 180ma - it’s in the specs somewhere.

Ordered both DS and SDIO card now, so that’s a step in the right direction i think.

1 Like

Sweeet! - have fun. That’s a few weeks work to get all that working I would guess based on my previous shabby projects. The DS is great audio board - bags of power and nice sounding audio output.

1 Like

If you just want the pitch of a monophonic whistle, you could even probably use a simple zero-crossing detector (maybe bandpass filter it to the expected range of fundamental frequencies).

I looked up zero-crossing detector, but I would have thought that unless you have a really clean sinusoid, it won’t accurately detect zero crossovers that are at the correct frequency? I hadn’t heard of them before reading your comment, so I’m not really able to say.

Try it, works great.