Make the CueCat beep when you scan (firefox only)

DiscussãoCueCat questions and help

Aderi ao LibraryThing para poder publicar.

Make the CueCat beep when you scan (firefox only)

Este tópico está presentemente marcado como "adormecido"—a última mensagem tem mais de 90 dias. Pode acordar o tópico publicando uma resposta.

1fizbin
Maio 20, 2007, 12:24pm

I don't know about anyone else here, but I am not that accurate using the :Cat, and often have to check whether I really scanned something in. This basically means that I have to be watching the screen as I scan stuff in so that I can see that some new encoded stuff got typed in.

This was inconvenient - what I wanted was something like they have in retail scanners, where the scanner makes an audible beep every time something gets scanned in.

So, since there's a plugin for firefox called greasemonkey that lets you tweak different web pages as you look at them, I played with that and now I am ready to release to the world lj-cuecat-beep.

Here's how to use it:
1) Be using firefox. This won't work for IE; anyone who wants to translate it for IE is perfectly welcome to do so, but I don't want to do that.
2) Install greasemonkey. (http://greasemonkey.mozdev.org) Greasemonkey is an extension that makes it possible for people to write things that are like tiny, page-specific plugins for firefox. I used this to make lj-cuecat-beep.
3) Make sure that your firefox can play midi files. There are a couple of different ways to do this; one of the easiest is to install or upgrade quicktime.
4) Go to http://snowplow.org/martin/greasemonkey/lt-cc-musictest.html and test that your firefox can play those two beeps.
5) Click on the "install the script" link there on that music test page.

Then, just go to the import page, turn your back to the screen, and scan something. You'll hear a beep when the :Cat starts "typing" and another beep when it's typed enough to know that you've scanned an ISBN barcode. (You get an error beep if you accidentally scan a UPC barcode)

If you're going to try this with your laptop's cover closed, I'll mention that for me that only works if I first make sure that there's only one firefox window open, and that one window is pointed at the import page.

2fizbin
Maio 20, 2007, 3:48pm

So because it was easy enough to do, I enhanced the greasemonkey script mentioned above so that not only does it make the noises, it also decodes the cuecat output so that you can be scanning a shelf, take a break, and come back and see where you were.

If you've already installed it, just go again to the music test page and install it again. It'll overwrite the earlier version.

Also, if you don't like my taste in beeps, you can replace the beeps with any other sounds you want. First, either find the sounds online or verify that you can play them in mozilla by going to a file: url for sounds on your local disk. Remember the url to the sound file.

Then, in firefox open a new tab and type "about:config" in the address bar. In the "filter" box type "lt-cuecat-beep", and you should see three options - the "fail", "start", and "success" sounds. By default, the values they're set to are long urls beginning with "data" that give the default beeps. You can change any of them to the url you remembered earlier.

To silence one of the sounds, you can change it in the configuration to:

data:audio/wav;base64,UklGRiQAAABXQVZFZm10IBAAAAABAAEAIBwAAEA4AAACABAAZGF0YQAAAAA%3D

(That should all be one long line)

3GreyHead
Maio 20, 2007, 4:50pm

Hi, looks neat but neither button beeps for me in FF. Am I missing a setting somewhere? QuickTime is installed I think, not sure if it's the default midi player though.

4fizbin
Maio 20, 2007, 8:20pm

Okay, a little bit of looking into it on other platforms showed me that some midi plugins for firefox expose the "play" function slightly differently than I had coded for. Please try again and see if the buttons give you sound now.

If it still doesn't work, you may need to reconfigure quicktime to play midi files in the browser as shown here:
http://kb.mozillazine.org/Quicktime#Quicktime_browser_settings

5GreyHead
Editado: Maio 21, 2007, 2:26am

Still no joy I'm afraid I get the following FireBug error message

Bad NPObject as private data!
playMusic("myMusic")
onclick(click clientX=0, clientY=0)

lt-cc-musictest.h... (line 5)

6fizbin
Maio 21, 2007, 6:28am

Ah. I think that's a symptom of having midi files in firefox handled by the flashplayer plugin, combined with flashblock.

Have you tried reconfiguring quicktime to handle midi files, as detailed on the kb.mozillazine.org site?

7GreyHead
Maio 21, 2007, 7:57am

reconfiguring quicktime to handle midi files Yes, I worked through all that. Not running FlashBlock as far as I know. And if I browse to a midi file like http://www.piano-midi.de/midis/schumann/scn16_3.mid then it plays in QuickTime OK.

8legallypuzzled
Editado: Maio 21, 2007, 7:07pm

Sorry. Neither the buttons nor the script is working for me, either. FF2 (although I do have Flashblock enabled; I'll try without later) with the LiveUpdate Crescendo plugin working fine on other MIDI pages.

Great idea, though. I'll try to keep testing this week!

Added: Looking at your embedded midi files .... are %s allowable characters in Base64 encoding? I don't remember seeing them before. Don't know if that's the issue or not ....

9fizbin
Editado: Maio 22, 2007, 12:02pm

percent characters aren't allowed directly in base64, but what's going on there is the interaction of base64 and URL encoding, which encodes special characters like / and = when they are used as data and not for some special purpose. Base64-encoded stuff often contains / and = characters.

I'm curious - if you cut-and-paste the data: uri that is the embedded midi file into your address bar, do you get a sound?

I guess I'll have to go get FireFox 2 and kick my stuff until it works in that; I still haven't upgraded.

Update: Still works for me, even in FF 2. (v. 2.0.0.3) I've added some diagnostic helpers to the test page though, so if you're still having trouble, please check again. (And be sure you refresh the page - FF 2 sometimes caches pages more than it seems it should)

10fizbin
Editado: Maio 23, 2007, 9:15pm

Okay, I think I've tracked this down: QuickTime 7.1.6 has serious issues being controlled via javascript in FireFox. I'd report the issue to Apple if I knew how - I've created a demonstration page that occasionally crashes my browser with QuickTime 7.1.6 but is absolutely fine in 7.1.3. (http://snowplow.org/martin/play_midi_js.html) Even when my browser doesn't crash, I don't get little beeps whenever I click on the page.

Unfortunately, this appears to be Apple's problem, and there's no way for me to fix it.

Note that 7.1.3 has some security issues with it that were fixed in 7.1.5, so you probably don't want to downgrade; I can't find a copy of 7.1.5 to check whether that had the javascript controls working or not.

Update: I found a 7.1.5 version, and it works too.

11GreyHead
Editado: Maio 23, 2007, 4:50pm

OK that fits - though I've only actually had one browser crash in many tests on your pages. The new demo one gives me the same "Bad NPObject as private data!" error in Firebug.

Oops - spoke too soon, it crashed when I closed the demo page.

12legallypuzzled
Maio 23, 2007, 7:18pm

User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3

Element 1: &91;object HTMLEmbedElement&93;
Trying to enumerate object:
nodeName : EMBED
nodeValue : null
nodeType : 1
parentNode : &91;object HTMLBodyElement&93;
childNodes : &91;object NodeList&93;
firstChild : null
lastChild : null
previousSibling : &91;object Text&93;
nextSibling : &91;object Text&93;
attributes : &91;object NamedNodeMap&93;
ownerDocument : &91;object HTMLDocument&93;
insertBefore : function insertBefore() {
&91;native code&93;
}
replaceChild : function replaceChild() {
&91;native code&93;
}
removeChild : function removeChild() {
&91;native code&93;
}
appendChild : function appendChild() {
&91;native code&93;
}
hasChildNodes : function hasChildNodes() {
&91;native code&93;
}
cloneNode : function cloneNode() {
&91;native code&93;
}
normalize : function normalize() {
&91;native code&93;
}
isSupported : function isSupported() {
&91;native code&93;
}
namespaceURI : null
prefix : null
localName : EMBED
hasAttributes : function hasAttributes() {
&91;native code&93;
}
tagName : EMBED
getAttribute : function getAttribute() {
&91;native code&93;
}
setAttribute : function setAttribute() {
&91;native code&93;
}
removeAttribute : function removeAttribute() {
&91;native code&93;
}
getAttributeNode : function getAttributeNode() {
&91;native code&93;
}
setAttributeNode : function setAttributeNode() {
&91;native code&93;
}
removeAttributeNode : function removeAttributeNode() {
&91;native code&93;
}
getElementsByTagName : function getElementsByTagName() {
&91;native code&93;
}
getAttributeNS : function getAttributeNS() {
&91;native code&93;
}
setAttributeNS : function setAttributeNS() {
&91;native code&93;
}
removeAttributeNS : function removeAttributeNS() {
&91;native code&93;
}
getAttributeNodeNS : function getAttributeNodeNS() {
&91;native code&93;
}
setAttributeNodeNS : function setAttributeNodeNS() {
&91;native code&93;
}
getElementsByTagNameNS : function getElementsByTagNameNS() {
&91;native code&93;
}
hasAttribute : function hasAttribute() {
&91;native code&93;
}
hasAttributeNS : function hasAttributeNS() {
&91;native code&93;
}
ELEMENT_NODE : 1
ATTRIBUTE_NODE : 2
TEXT_NODE : 3
CDATA_SECTION_NODE : 4
ENTITY_REFERENCE_NODE : 5
ENTITY_NODE : 6
PROCESSING_INSTRUCTION_NODE : 7
COMMENT_NODE : 8
DOCUMENT_NODE : 9
DOCUMENT_TYPE_NODE : 10
DOCUMENT_FRAGMENT_NODE : 11
NOTATION_NODE : 12
id : myMusic
title :
lang :
dir :
className :
align :
height : 10
name :
src : data:audio/midi;base64,TVRoZAAAAAYAAAABAeBNVHJrAAAAJQD%2FUQMHoSAA%2F1kCAwAA%2F1gEBAIwCADAKgCQTGmDX4BMAAH%2FLwA%3D
type : audio/midi
width : 20
getSVGDocument : function getSVGDocument() {
&91;native code&93;
}
offsetTop : 138
offsetLeft : 113
offsetWidth : 20
offsetHeight : 10
offsetParent : &91;object HTMLBodyElement&93;
innerHTML :
scrollTop : 0
scrollLeft : 0
scrollHeight : 10
scrollWidth : 20
clientHeight : 10
clientWidth : 20
tabIndex : -1
blur : function blur() {
&91;native code&93;
}
focus : function focus() {
&91;native code&93;
}
spellcheck : false
style : &91;object CSSStyleDeclaration&93;
removeEventListener : function removeEventListener() {
&91;native code&93;
}
dispatchEvent : function dispatchEvent() {
&91;native code&93;
}
baseURI : http://snowplow.org/martin/greasemonkey/lt-cc-musictest.html
compareDocumentPosition : function compareDocumentPosition() {
&91;native code&93;
}
textContent :
isSameNode : function isSameNode() {
&91;native code&93;
}
lookupPrefix : function lookupPrefix() {
&91;native code&93;
}
isDefaultNamespace : function isDefaultNamespace() {
&91;native code&93;
}
lookupNamespaceURI : function lookupNamespaceURI() {
&91;native code&93;
}
isEqualNode : function isEqualNode() {
&91;native code&93;
}
getFeature : function getFeature() {
&91;native code&93;
}
setUserData : function setUserData() {
&91;native code&93;
}
getUserData : function getUserData() {
&91;native code&93;
}
DOCUMENT_POSITION_DISCONNECTED : 1
DOCUMENT_POSITION_PRECEDING : 2
DOCUMENT_POSITION_FOLLOWING : 4
DOCUMENT_POSITION_CONTAINS : 8
DOCUMENT_POSITION_CONTAINED_BY : 16
DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC : 32

To source: {}
Searching for known methods:
Play : undefined
play : undefined
stop : undefined
Stop : undefined

13fizbin
Maio 24, 2007, 11:21am

Well heck. I went and modified the script so that it would beep using some ancient java code (Just the default system beep; I can't change the tone, sorry) if it can't do anything else. No audio cue when you scan a UPC symbol by mistake, but it's something.

The test page has been updated to reflect this.

Unfortunately, Apple broke QuickTime's firefox plugin on Windows with the 7.1.6 upgrade, such that I can't control anything QuickTime is doing with JavaScript. I'm using 7.1.5 now and that works fine.

I may eventually work out a second all-java solution to generating sounds, but not now.

14legallypuzzled
Maio 24, 2007, 7:14pm

For what it's worth, I did get the "Last Resort" beep.

15fizbin
Maio 25, 2007, 2:26pm

Okay, so I lied about not working on the java-based sounds solution. Turns out it was really easy after all, though I'd appreciate a better set of .wav files for the java version. Now, even people with the broken quicktime version 7.1.6 can use the script.

Updated instructions are on the music test page.

Note that my script does not work with a "declawed" (that is, not encrypted) CueCat, but only because I don't know in full detail what kind of output those things produce. (Mine is a fully clawed PS2 version I got back when they first came out, that I'm using through a PS2-to-USB adaptor) If anyone who has such a beast is willing to email me back and forth a few times, it should be easy to adapt the script to handle those too.

16GreyHead
Maio 26, 2007, 3:02am

Oh!! In a rush right now - but the top buttons on the page (the midi ones) now work perfectly. Will check with my declawed CueCat later today - happy to check out the operation with you by e-mail. The declawed CueCat just sends an alpha string of the ISBN-13 followed, I think, by a CR/LF of some kind.

17fizbin
Maio 26, 2007, 7:55am

Huh. Yeah, it appears that the midi buttons do now work with QuickTime 7.1.6, but I don't know why. I don't know which change it was that allowed them to work.

Until I do know, I would strongly encourage you not to trust javascript-controlled midi files and switch lt-cuecat-beep over to using java for sounds if you're using QuickTime 7.1.6, as using the greasemonkey script with 7.1.6 will occasionally crash firefox. (but not always; sometimes it works)

The declawed cuecat sends just the barcode plus enter? No prefix that identifies the barcode type? No attention key? (the original cuecat sends ALT-F10 before sending anything) What does it send if you scan a UPC code?

18GreyHead
Maio 26, 2007, 8:04am

I don't know if it sends Alt-F10 - my guess is not, it should just behave as a keyboard input device. Here are a few random scans off things lying around my desk (clearly you can't see any control codes here).

9780446692786 51395
802699201122
9780194379649
5000358380910

19legallypuzzled
Maio 26, 2007, 2:18pm

Hmmm ... the top buttons don't work for me, but the middle ones do. I'm sure I still have a clawed CueCat somewhere, but it will take a while to find. The one plugged in is declawed.

20fizbin
Maio 26, 2007, 7:45pm

Huh... that's going to be harder to track - would either of you with a declawed cuecat care to go to http://snowplow.org/martin/catchkeys.html , press the "Start capture" button, scan something, then copy and paste the results into an email to me (my address is on that page, just remove the dashes)

21GreyHead
Maio 27, 2007, 12:20am

Have - done: 802699201122CR

22fizbin
Maio 27, 2007, 3:45pm

Okay, I modified it to hopefully beep properly with a declawed cuecat. It can't detect when a declawed cuecat starts typing, so you only get a sound when the cat has scanned something. It is able to detect accidentally scanning a UPC code or a non-Bookland EAN, and will play the failure sound then.

It detects a declawed cuecat by the timing of keydown events - the cuecat is amazingly consistent in the timing of keydown/keyup events, and the timing of those events isn't affected by running lots of javascript. (running javascript when receiving events can affect the timing of keypress events, but not the timing of keyup or keydown)

In my testing and in what GreyHead sent me, adjacent keydown events are always either 15 or 16 milliseconds apart. The code accepts any sequence of keydown events consisting of just numbers, spaces, and return that is consistently between 13 and 18 milliseconds between events as being from a declawed cuecat.

I strongly recommend that if you have QuickTime 7.1.6, you install the script and then when you load up the "addbooks" page, switch the script to using java for sounds (under the menu Tools->GreaseMonkey->User Script Commands), and that you flush out the browser cache before you go to the music test page. (I updated the sound files inside the java .jar, and so you might want to make sure you grab a new copy)

23fizbin
Set 22, 2007, 5:01pm

Note that when Apple released Quicktime 7.2, they fixed this bug. Midi sounds are back again for everyone.

24mdhuang
Editado: Out 7, 2008, 10:16am

Here is a windows command file to make the cuecat beep when scanning (I only use it for declawed version. It may also work for unmod version if there is a line feed character at the end of each scan).
----------------------------------------------------
ECHO OFF
ECHO Type exit to quit.
:REPEAT
SET /P INPUT=CUECAT:
IF "%INPUT%" EQU "exit" GOTO QUIT
ECHO %INPUT% >> cuecodes.txt
SET INPUT=
mplay32 /play /close "C:\\WINDOWS\\media\\ringout.wav"
GOTO REPEAT
:QUIT
----------------------------------------------------
Just copy the above commands into a file named cuecat.bat and double click it. Now you can start scanning. Each scan will make a beep. When you are done, type "exit" to terminate. The resulted codes are in a file named cuecodes.txt which you can then import or copy/paste into LibraryThing or other programs.

25BTRIPP
Editado: Set 23, 2008, 11:03am

Re. #24:

Oooh ... which means you could substitute any preferred sound file for "ringout.wav"?

heh, heh, heh ... picturing the "farting CueCat"!


26mdhuang
Set 23, 2008, 11:15am

You are right :-)

27caubles
Out 1, 2008, 9:19pm

Can anyone mod this to go ahead and add the found book like "Skip Confirmation" is supposed to?

28caubles
Out 1, 2008, 9:34pm

FWIW,

I am running FF on OS X with QT 7.5.5.

1) The sound buttons on the page work, but the script makes no sound unless I enable java for the script.
2) I only hear the success sound, not the start sound.
3) Subsequent scans make no sound unless I manually clear the field. The field does not clear itself.

29jjmcgaffey
Out 3, 2008, 10:32pm

27> No, not related. That's an LT thing that stopped working. Hopefully when they get done with the latest lot of stuff they'll fix the skip...it's a pain!

30VineLibrary
Jun 21, 2009, 12:05pm

Hey thanks! It works and I like it! JM