This is the bug/patch tracker for Rockbox. Click here for more information.
Quick links: Bugs · Patches · Rockbox frontpage
FS#5111 - Ipod piezo driver
Attached to Project:
Rockbox
Opened by Robert Keevil (obo) - Thursday, 13 April 2006, 01:34 GMT+1
Last edited by Dave Chapman (linuxstb) - Thursday, 13 April 2006, 19:12 GMT+1
Opened by Robert Keevil (obo) - Thursday, 13 April 2006, 01:34 GMT+1
Last edited by Dave Chapman (linuxstb) - Thursday, 13 April 2006, 19:12 GMT+1
|
DetailsFirst attempt at a piezo driver for ipods - works, but needs a lot more done to it yet.
|
This task depends upon
Sound needs to have a period of 26 or 27, for a duration of 0.004 or 0.005 seconds. I don't know any way of making Rockbox sleep for that short a period (also the sleep function always seems to do a sleep + 1), without changing the definition of HZ. Setting HZ to 1000 produces some very funky button handling.
Whether we should be slavishly trying to emulate the sound of RetailOS is another matter... but I think a default beep and click would be good, just not sure what settings to use.
It also beeps during volume change in the WPS - I haven't yet looked at trying to stop this.
I've also wrapped all the piezo functions in button.c with #ifdef HAVE_PIEZO - makes it compile cleanly on other platforms. Could have just done a (void)tpe, but didn't see the point in calling something that did nothing.
Looks like the piezo commands can be decomposed as:
0x80000000 : sound on if set / off if 0
0x7f000000 : doesn't seem to have any effect
0x00ffe000 : seems to be some kind of wave form modifier (not sure about 0x0000e000 though)
0x00001fff : frequency
You can find a small test plugin here: http://people.videolan.org/~dionoea/ipodtest.c
Button click duration
Button click frequency
Add check on piezo_button_beep to prevent the queue overflowing - any better ways to do this?
1. Beeps are too long. Yes, I know I told you not to use the user timer for shorter durations, and we still can't do that, thanks to backlight fading also using it. Any other ways of doing it?
2. I don't think the options are necessary. A retailos-ish beep should really be enough.
2 - changed the options to a bool only. Retailos pitch and duration may need tweaking.
Maybe a menu option or just to say what and where to edit the patch.
Either way, thanks so much for syncing it. Much appreciated!
1) it should probably be HAVE_HARDWARE_CLICK or something instead of piezo
2) the setting should be similar to the ipod OD where you can click in the piezo/headphones/both
3) it should be handled in the same way and places as the software click
Changing to hardware_click makes sense to me on more than on level, since before I actively searched for this topic I had no idea what piezo was... maybe that's not necessarily keping people from realizing this feature has been worked on, but it kept me in the dark for a while.
And of course, calling it hardware click makes sense with the other kind being a software click.
I wish that I could do more to help see this in svn, but I have trouble even applying patches, let alone writing them. I don't suppose there's anything non-code related I could do to help out?
Disclaimer: I haven't tried the patch yet, so I don't know how "different" it is from the OF. We certainly need confirmation on this one.
It does sound different than the standard iPod click, but personally I don't mind it. I might play with it later.
And once again, thanks for taking the time to work on this. It's honestly the only thing I miss about the normal firmware.
1) Is there a possibility of hearing the click only through the speaker, or through the headphones? It would be nice to have the option to select none, either, or both (even though the OF doesn't allow this, to my knowledge, it would be kinda neat).
2) Is there a way to disable/adjust the click when adjusting the volume/doing other WPS things? The click can disrupt the sound a bit, and with crossfade turned on, having a click sounding on track change becomes semi-unnecessary (unless you definitely want to know that the track change was registered without looking at it). I know that for the OF, the clicks still occur when changing volume, but they seem to have made them less frequent when doing so.
Those two are more of a personal preference, but the last one is an actual problem. I'm still getting weird beeps when I scroll too fast, only now it's coming from the speaker as well as the headphones. It's not particularly loud, about the same volume as the clicks, but more piercing and annoying. I guess the cause of this is still unknown? Is there anything that can be done about it at this point?
yield();
to :-
if (duration >= 5000) yield();
If not, I'll make a patch file up for you soon - I'm just playing with another patch and have the source code in bits. I can look at reducing the frequency of the clicks, but at moment its in line with the rockbox software keyclick code.
-headphones
-speaker
-both
-off
It's perfectly fine as-is though, so unless anyone else feels that way/my wording of it just changed your feelings on it, I wouldn't worry about it.
As to feeling adventurous, I may look into what you were talking about... it sounds like whatever you're doing with the source now is bigger than that, though, and I may just wait to see what you've got up your sleeve. Thanks again for the hard work.
1) With keyclick repeat on, holding down any button will make the device start clicking rapidly. This should probably be altered so that a single button press, even a held one, still produces a single click. This wouldn't be applied to the scroll wheel, since it needs to continue to click when doing things like changing volume (albeit less frequently, as I suggested) and scrolling through lists. I know that right now using the repeat mode probably isn't so conditional, but to add those tweaks would probably be useful, if they're doable.
2) Since 'keyclick' is the name of the overall setting menu, 'headphone click' and 'speaker click' are probably simpler and less repetitive than saying 'keyclick' again in full. probably works for 'click repeats' as well. Besides that, I think the new wording and setup looks much better.
3) When scrolling through lists (again, with repeat enabled), I was thinking about another handy tweak that might be likeable, if it could be done... on my super-duper cool phone (the newer chocolate), when I'm scrolling through lists, it makes a beep noise instead of a click when wrapping from the bottom back to the top (or vice-versa). This is another thing that, if implemented, would assist in navigating without needing to look down at the screen, as you can tell when you've wrapped around and can do things like scroll immediately to the bottom of a list and then four up to the song you want, just by hearing the beep and four clicks (the tone wouldn't need to be a beep, of course). Does anyone else think that would be useful, and is it doable?
I'm very impressed with all of the work. You're a machine! I'll be interested to hear how the current click stacks up against the nano's side by side. Please let us know, and I hope my comments are more helpful than annoying...
3) yes this is doable, sort of... possibly the best thing we can do is beep when you get to the top/bottom of the list because in most lists it wont let you wrap untill you release the button
3) Currently if you continue to scroll after reaching the bottom, the ipod continues to click away as if you're still scrolling through something. Ideally, this is where something should just tell the click to stop, rather than make a beep that could be lost in the current series of clicks. Once it stops clicking here, you would know to stop scrolling for the moment so one could wrap the list, and once the wheel is pressed again, when the code sees you can't go any further and loops back to the top, I think that a beep should be made (and scrolling up instead would just return to clicking). There has to be code in there telling the list to loop, so it sounds like it should be doable to make that loop produce the beep.
As for 2) - I quite like the word Keyclick, I don't think Click "looks" right. My personal opinion.
Back to the patch, the change causing a button hold to not click like crazy is REALLY GREAT. Is it doable to make the device stop clicking when you've scrolled to the bottom of a list, as well? That will probably be more useful than the beep idea anyway. If the device isn't clicking anymore, I would know I've reached the top or bottom of the list anyway, and could go from there (the same idea could also be applied to changing volume, so one knows they can't turn the volume up/down anymore?).
Finally, your opinion on liking 'keyclick' over 'click' is totally justifiable, and it's definitely not something I feel the need to defend any further. 'Keyclick' sounds fine to me.
Anyways, yes I agree with Glenn it's really great it doesn't click like earlier when holding a button.
I think it isn't too difficult to let it stop clicking when at the bottom of a list or menu. Later this day I'm gonna try to remove that beep by myself (I have some basic C skills, still learning more and more).
It's really great to see people this interested in getting this up and running so well! I'm simply overjoyed.
To make it stop clicking when at bottom of menu seems a bit more tricky, the keyclick is produced on response to the buttons in "\apps\action.c" without knowing where it is in the GUI. I think some information/opinion from jdgordon on this is needed, as (again) its going from more than an iPod thing and could be an option to change behaviour of software keyclick too.
Offtopic: Is it normal that crosscompiling in Cygwin takes almost an half our? I'm running on a Celeron M 1,5 Ghz.
I also noticed after crosscompiling my memory usage is increased from approx. 300 mb to almost 1000 mb, and it just stays at that height. I have to reboot to get it back to normal. I'm thinking to install Debian or so for Rockbox compiling on my laptop.
Here it is:
I've also reduced the pitch of the clicks to try and make it match better. I've got my friends 1GB iPod nano, and his OF click sounds quite a bit different to my 4GB nano OF click - both are same firmware versions, maybe damage to one of the piezo or just natural variation.
Some observations/other thoughts:
1) Some testing revealed that keyclick now repeats no matter what. Personally, my question is: who needs this option? To me, turning off repeat was only really important to me when the thing was still beeping when used too quickly, and I never really wanted the click just to know I've made a general action. If people think this is still useful, it will need to be fixed, but I'd appreciate it if someone would tell me its purpose. In addition, now that it's working very nicely, would anyone object to 'keyclick repeats' defaulting to 'on' (this is not asking for the keyclick to be defaulted to on, just the repeat function)? Once again, I think this was defaulted to 'off' because of the beeping. Just thought I'd throw that out there.
Actually, I just found out what turning on 'keyclick repeats' does: it seems to give the exact same behavior, but it brings back the crazy clicking when holding down a button. So right now, setting this feature to 'off' is actually giving me the behavior I was looking for. Weird. So actually, if you want to get technical, the 'off' feature is correct: going through a list is not holding down a button, so that's not a click repeat. Same with changing volume. So actually... I guess that as-is, I'm not seeing any need for the 'on' function. Interesting. If this is what everyone else wants, do we need this option anymore?
2) Some more testing (actually plugging in headphones) revealed that the headphone click is now tied to the speaker click. When I turn on the speaker click, it enables the headphone click even when the headphone click is still off. This isn't as big a deal at the moment, since the click noise is much easier to deal with in its lower pitch, but should still probably be cleaned up. Also, turning on headphone click and disabling speaker click gives me no clicks at all. As opposed to the repeating options, I do think that it is a good idea to be able to toggle the headphone and speaker clicks independently. I don't necessarily understand needing to adjust the volume of the headphone click, but that should probably be left up to people who use it.
3) As I've said before, I still think that it would be very simple to have this in the 'Keyclick' menu:
-headphone keyklick
-speaker keyclick
-both
If the volume of the headphone click was sufficient for everyone (and the repeat thing was deemed to be properly implemented), then we've knocked out a whole set of further settings to navigate through, in favor of three simple options (basically, "where do you want your clicks coming from?"). I'd like to hear people's thoughts on this, as well.
4) Finally, having seen that we can use action handling code to make the clicks work in specific ways in lists, can the same thing be done with the volume handling? For example, is there a piece of code that can retrieve the current volume (I'm assuming there is, so that the gui can be updated), and if so, can that be used like the list code was used to stop clicks at the minimum and maximum volume limits?
To take this a step further, in an attempt to try and understand how the OF slows its clicks when changing volume... perhaps a click could only be given every five decibels, or something like that? I don't know if the code could be made to work this way, but it's a thought.
Once again, sorry to unload a ton of information all at once. I just don't want to forget anything, and I'm all giddy about all the work that's been done lately. Keep up the amazing work.
I can look at reducing the frequency of clicks whilst using clickwheel in CONTEXT_WPS to give the desired clicks for volume changing. At the moment, I don't know about stopping it clicking on min and max volume though.
Also, a penny for your thoughts regarding the other stuff I blabbered on about?
The 'Headphone click', as my patch now calls it, is Rockbox default software keyclick - which on iPods doesn't work correctly, and on my iPod nano only really works when I have music playing or before I press play after a restart - related to bug FS#8836 .
On the iPod, the clickwheel motion of scrolling until you stop behaves as a single keypress, ie. holding down the button - so default behaviour is no repeated clicking when keyclick repeat off - the patch overrides the "Keyclick repeats" option for the clickwheel only (coming from the speaker - it doesn't alter the behaviour of the software click). The "Keyclick repeats" is there for other keys and other players. The crazy clicking on button press is the keyclick repeat working correctly. Perhaps a new task (or this one??) should be started to change the keyclick for the ipod in general.
The volume options for the software click come from the Rockbox normal menus - when the software click does work, they do make a difference and I can see people having different preferences.
Its the headphone click tied to the speaker click that I'm interested in - I don't know if there is there a way to make the piezo drive to the headphones?? The software and hardware options are different - I've double checked, but I did change the parameters to the piezo to try and improve the click. On my nano it behaves as it should do, I've made some more small changes to the patch in preparation to try looking at the volume magic later.
Hopefully that's what you meant.
I would make the point that whether they use the same code or not, the two clicks should probably eventually end up doing the same thing (or at least have the same sound). Like I said a while ago, it would be weird to have them both on and doing different things. We'll see where it goes when we come to it. I'll admit I'm constantly forgetting that this needs to work in some other targets besides ipods, so I'll need to be more conscious of that when it comes to brainstorming in the future.
I'll say one last thing in this task in regards to the headphone click: it's nowhere near as sophisticated as you've gotten the speaker click. I'm probably never going to use it, but I hope when this task is done you'll think about cleaning up the headphone click for all ports to enjoy.
To reproduce:
1) Apply patch
2) Start Rockbox
3) Enable speaker click
4) Cover your ipod with something, I guess. or drown it out some other way. You've got to be able to hear this. Just scroll up and down a list.
5) Play a music file. Scroll the volume up and down. When it gets low, the click can be clearly heard. As you up the volume, the song fades in, but the click fades out (or maybe stays the same and is drowned out, I can't tell).
Please, someone confirm this. If it's really not just me, then we have a headphone click already for some reason... it's just not audible when the volume is up for some reason. Tested on a fresh source.
All I can suggest is to try this patch - I've put the click back to how it was but still at a lower pitch. Remember that we do have different hardware, maybe I've stumbled on the hardware headphone click for the ipod video (like the OF on headphone setting)??? - but for my nano I get nothing. Also, the volume click in the WPS is now every 6 dB.
First of all, this patch still gives me the magic headphone click on my firmware. If you're trying to reproduce, use the steps in my last post, but for 5: "Play a music file. scroll the volume up and down, THEN GO BACK INTO A MENU AND SCROLL UP AND DOWN A LIST AGAIN (before you could test it by just continuing to turn the volume down, but now that it doesn't click after reaching the bottom, this isn't the easiest way to test). When volume is low, the click can be heard. When the volume is up, it sort of fades away." Apparently this doesn't work on the nano, so if anyone at all has a non-nano ipod, please test this for me and tell me if I'm nuts or not.
Second of all (and most importantly), this patch pretty much does everything that the OF click does, at this point. The click stops at the end/beginning of a line, and stops at the minimum and maximum volumes. Clicking every 6 dB sounds pretty good (I might go even higher, maybe seven or eight? Hard to tell without hearing it), and the fact that you accomplished all of this at all is just great. The click is sounding good, too (especially comparing it to the original rockbox click). Is there anything else that should be set as a goal for this specific type of keyclick? JDGordon, what are your thoughts on what this patch still needs before it would be considered for committing?
This patch also includes the test plugin from dionoea near the start of this task. Glenn, if you could first of all test the previous patch that didn't give the magic headphone clicks, to make sure it still doesn't, then apply this patch and start up the piezotest plug-in under applications. The piezo sounds if enabled is greater than 0x80. I changed the waveform from 0x80 to 0xF0 before when you first said the problem, and reduced the freq from 0x32 to 0x5B (lower freq is an increase in the value). I guess its a case of see if the buzzing comes through your headphones.
Either way, I'll go back and test right after we removed the beep when looping. I'm still not quite sure what you're asking me to do with the plugin, but hopefully I'll know when I actually see it. And if not I'll ask.
Myquestions to everyone else still stand! We need more than just my feedback...
Craig, I was rolling backwards through your patches, when I realized I should start from your initial commits and move forward. Your initial sync doesn't compile for me, and the one after that (when you moved all the settings to where they are now)... gives me magic headphone click. So I have no idea. We really need someone else to confirm this. It's definitely there... I'm literally holding my ipod under a pillow, and I can only hear it clicking with my headphones on. I have no explanation as to why it only seems to be happening on my video, though.
And don't get me started on how weird it sounds when I enable both (this is on more recent patches)... without repeat on, I hear the different-pitch headphone click with every first click, followed by little subsequent (different pitch) clicks (the magic ones). With repeat ON, it gets kinda buggy. The headphone click beeps sometimes, but the magic clicks don't. Curiouser and curiouser.
What would happen if we commented out all the headphone click code? Could you make a patch that does that? I'm wondering if disabling all headphone click junk may disable something that's been magically tied to the speaker click on my build. If it does, then I would know that something in that code is the culprit.
In the meantime, I'm going to test out the newest patch, with the plugin. I'll let you know my results.
Really, I would say this is an issue similar to the beep experienced in the software click... it's a weird little quirk, but it shouldn't stop the task from being committed. Maybe adding this to the main build will inspire someone with more knowledge to work out what it is that's happening (which is what happened when software click was sent out into the wild, I think). I'd be perfectly fine seeing this committed, even with my phantom clicks. That's just my opinion, though.
So, two final things before I turn in for the evening... turning off the click in OF and rebooting didn't change anything (unfortunately... it was a good idea, though). Secondly, I'm wondering if you might be able to make me a special patch... one that lets me choose the frequency of the volume click. I keep testing these builds and thinking I'll know the right number of dB to click to, but I really can't figure this one out. if it's possible to make it an option for a patch (one I would NOT want to see in a final commit, just one so it can be tweaked to find the right value for this one), that would be awesome. Maybe it's just that this volume thing is the last real issue bugging me about this task, but I'd like to get this one just right before I'm 100% behind it being committed.
If a patch for that can't be easily made, I would say stick with your original click every 6 dB. maybe it's just me having finally realized that the OF doesn't do this, but the more I'm using these high number intervals, the less they sit right with me. Might go even lower than 6 at this point. Sorry for being so wishy-washy.
I think that looking back at JDGordon's initial thoughts on what the patch needed, the only thing still really missing is his number three: "it should be handled in the same way and places as the software click." Because the piezo click has now (in my opinion) surpassed the headphone click in functionality, it is doing some things differently than the piezo click does. Are these things this patch should work to reconcile? If so, it would make sense to work on it and get that obstacle out of the way. If it is something that should not be addressed by this patch, like I said before, is there anything else that would block this from being committed?
So I guess what I'm wondering, once again, is if any higher-up people would like to revise the "to do" for this patch, to get it up to the level where it can be considered for submission (post-3.0). Anything besides click frequency in changing volume (which should definitely go back down to every 4 db, or something around that, after having lived with the higher one for this time), and possibly getting the features of this patch matching the current headphone click functionality (in this task or a new one)?
Either way, Craig, don't give up on the patch. You've done really solid work bringing this patch to the level it's at, and I know I appreciate it very much. I hope you'll be back at some point to show this task some more love. Thanks again.