Wikipedia:Reference desk/Archives/Computing/2017 August 19
Computing desk | ||
---|---|---|
< August 18 | << Jul | August | Sep >> | August 20 > |
Welcome to the Wikipedia Computing Reference Desk Archives |
---|
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages. |
August 19
[edit]Java: call overridden method to get constructor parameters
[edit]I have an abstract class, one of whose constructors needs to call an abstract method to determine what size of byte array to generate as a PRNG seed. Doing this the obvious way gave me the error "cannot reference this before supertype constructor has been called", and even trying to do it via reflection gave me "cannot reference Object.getClass() before supertype constructor has been called". So I ended up with this very ugly workaround:
private static final HashMap<Class<? extends BaseRNG>, Integer> seedLengthsForClass = new HashMap<>(); private static final Objenesis objenesis = new ObjenesisStd(); private static int getMyNewSeedLength() { try { int stackTraceDepth = 2; StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace(); Class<? extends BaseRNG> clazz; do { clazz = Class.forName(stackTrace[stackTraceDepth].getClassName()); stackTraceDepth++; } while (Modifier.isAbstract(clazz.getModifiers())); Integer seedLength = seedLengthsForClass.get(clazz); if (seedLength == null) { seedLength = objenesis.newInstance(clazz).getNewSeedLength(); seedLengthsForClass.put(clazz, seedLength); } return seedLength; } catch (ClassNotFoundException e) { throw new RuntimeException(e); } } public BaseRNG() { this(DefaultSeedGenerator.getInstance().generateSeed(getMyNewSeedLength())); }
(NB: For those unfamiliar with it, Objenesis is a library that creates instances of a concrete class without running a constructor, using various JVM-specific backdoors.) Are there any better ways to work around this particular error, without requiring all subclasses' constructors to duplicate each other's `super(SEED_ARRAY_SIZE)` call? None of the subclasses have getNewSeedLength()'s output vary between instances, but it does vary according to the subclass. If this isn't evidence that we need abstract static methods, then I'd like to know what would be. NeonMerlin 06:19, 19 August 2017 (UTC)
- Can you provide an example of code that threw that error? Ruslik_Zero 19:08, 19 August 2017 (UTC)
How to send PC left and right middle mouse button movements
[edit]The middle button of my Logitech G500 mouse can be moved left and right (as well as scroll up and down and be pressed as usual for the MMB). I can't detect my mouse button presses with a keycode scanner but I'm trying to find out what is happening; what signal is being sent to the computer so I can send the same signal via such utilities as AutoHotKey or with a custom Android remote made in the Unified Remote? --145.255.246.8 (talk) 15:20, 19 August 2017 (UTC)
- They would normally generate mouse click events, much like the other buttons do. If they scanner program isn't reporting them, it may be that they are already being reinterpreted (presumably by the Logitech driver) and turned into something else (or nothing) by it. So I suggest you look in whatever Control Panel thing or config utility Logitech have supplied to see if there are options there to configure how those buttons work. -- Finlay McWalter··–·Talk 15:42, 19 August 2017 (UTC)
- Some searching around suggests that the mouse comes with a rather elaborate utility called "Logitech Gaming Software", which has some extensive options for mapping the mouse controls (including per-game options). -- Finlay McWalter··–·Talk 15:59, 19 August 2017 (UTC)
- For example, this image shows that software's display of an input profile on the G500 - note that this specific profile maps scroll commands to the left and right movement of that central wheel button. -- Finlay McWalter··–·Talk 16:14, 19 August 2017 (UTC)
- Thanks but I already know this. I want to know what signal is being taken by the operating system so that I can simulate the signal. The keyscanner doesn't recognise the left mouse button either. The sideways scrolling using this left/right action of the middle mouse button/wheel works in numerous programs including one which I know does not respond the same way to the arrow keys (Hitfilm Express 2017) so I want to know what signal is being delivered by the driver to whatever it is the driver talks to. Something, somewhere is telling the programs to scroll left and right and I'd like to know what it's saying. The Logitech utility does not yield this information and is only useful for changing what the buttons do which is of no interest to me because I like what they do; I only want to emulate it. 145.255.246.8 (talk) 17:35, 19 August 2017 (UTC)
- https://www.autohotkey.com/docs/KeyList.htm#SpecialKeys near the bottom. Also read step number 3 here https://autohotkey.com/board/topic/111737-how-to-make-ahk-work-in-most-games-the-basics/ (((The Quixotic Potato))) (talk) 02:38, 20 August 2017 (UTC)
Watson online
[edit]Is there any webside powered by some sort of Watson? Somewhere we I could ask a natural language question like "Is orange a fruit?" and obtain a yes/no answer. The closer I can find is Wolfram Alpha. --Hofhof (talk) 16:53, 19 August 2017 (UTC)
- When I type that Q into Google I get "Orange trees are widely grown in tropical and subtropical climates for their sweet fruit. The fruit of the orange tree can be eaten fresh, or processed for its juice or fragrant peel. As of 2012, sweet oranges accounted for approximately 70% of citrus production." Of course, it's not really parsing the sentence as a question, but rather extracting the nouns from it and looking for sites which contain "orange" and "fruit". However, I think that's what Watson tends to do, too. But the results are often good enough. StuRat (talk) 21:39, 19 August 2017 (UTC)
Music recognition
[edit]I'm confused as to where to place the question: Here or in Entertanement or in Science. I will try here first.
I am interested in electronic devices (API's) that do music recognition. If you google like I did for "music recognition[1]" (MR) a number of websites come up. I want to know what they all mean. For some MR means lyrics identification and saying: "This is the song which is known as such." I want to define my understanding of music recognition. I think the API should be able to identify all the notes or chords in the piece played be it an operatic aria or a popular song. The music identification in terms of the naming the piece is a sort of a secondary attribute and requires a library.
So, what is the music recognition in all those websites? Thanks, --AboutFace 22 (talk) 22:15, 19 August 2017 (UTC)
- I don't think music recognition software is able to "identify all the notes or chords". Some software uses methods like the ones described here http://www.similarityapp.com/faq#q-methods but I think you are more interested in Acoustic fingerprinting and Automatic content recognition. (((The Quixotic Potato))) (talk) 00:57, 20 August 2017 (UTC)
- You might be interested in automatic music transcription. SampleSumo MeloTranscript API says it can transform "monophonic melodies into musical notes" (website). This list of Music APIs has a category for Audio Identification. There has been some success with the polyphonic problem. StrayBolt (talk) 23:06, 20 August 2017 (UTC)
Thank you, @The Quixotic Potato. --AboutFace 22 (talk) 12:38, 20 August 2017 (UTC)
- Shazam (service) has a list of similar apps. I use SoundHound for iOS.
Sleigh (talk) 21:59, 20 August 2017 (UTC)