How to solve a problem related to the implementation of the legacy?
HelloThen I come on this way to ask for assistance on the implementation of the legacy on my request. So the problem is:
I apply I need to capture audio and analyzing this capture of the Spectrum Analyzer, Volumes etc.
So I will use several microphones in this application, I will use the same code in the audio capture.
I have a class called Application which has GUI and events, such as events of button and update the values in the GUI. In my first version of the Application, I have everything here, but I had Don t like that and is not good for performance, so I want to divide the code by other classes. That's why I try to the legacy.
So I created a class called equipment which is the super class and in this class will have the method captureAudio(), the calculateRMSLevel(), the sendOutPresenceUpdates() etc... And I have 3 variables:
public abstract class Equipment {
public AudioFormat format;
public TargetDataLine line;
public Mixer mixer;
public EventListenerList listenerList = new EventListenerList();
public Equipment(AudioFormat format, TargetDataLine line, Mixer mixer){
this.format = format;
this.line = line;
this.mixer = mixer;
}
public AudioFormat getFormat() {
return format;
}
public void setFormat(AudioFormat format) {
this.format = format;
}
public TargetDataLine getLine() {
return line;
}
public void setLine(TargetDataLine line) {
this.line = line;
}
public Mixer getMixer() {
return mixer;
}
public void setMixer(Mixer mixer) {
this.mixer = mixer;
}
public int calculateRMSLevel(byte[] audioData){
// audioData might be buffered data read from a data line
long lSum = 0;
for(int i=0; i<audioData.length; i++)
lSum = lSum + audioData;
double dAvg = lSum / audioData.length;
double sumMeanSquare = 0d;
for(int j=0; j<audioData.length; j++)
sumMeanSquare = sumMeanSquare + Math.pow(audioData[j] - dAvg, 2d);
double averageMeanSquare = sumMeanSquare / audioData.length;
return (int)(Math.pow(averageMeanSquare,0.5d) + 0.5);
}
public void sendOutPresenceUpdates(int FullJIDAndResource, String NewPresence) {
Object[] listeners = listenerList.getListenerList();
Integer inputValue = _FullJIDAndResource;
String convertedValue = inputValue.toString();
// Empty out the listener list
// Each listener occupies two elements - the first is the listener class and the second is the listener instance
for (int i=0; i < listeners.length; i+=2) {
if (listeners[i]==CustomPresenceListener.class) {
((CustomPresenceListener)listeners[i+1]).presenceEventOccurred(new CustomPresenceEvent(this, convertedValue, _NewPresence));
}
}
}
public void listenForPresenceEvents(CustomPresenceListener _listener) {
listenerList.add(CustomPresenceListener.class, _listener);
}
public void removeEventListener(CustomPresenceListener _listener) {
listenerList.remove(CustomPresenceListener.class, _listener);
}
public void captureAudio(){
}
And i have questions about the constructor, is right the constructor that i created in the superclass?
So i create a subclass called Microphone1 and in this class i make override from the method captureAudio() from the superclass and here i create the thread for the capture.
class Microphone1 extends material {}
Public Microphone1 (format AudioFormat, line TargetDataLine, drummer mixer) {}
Super (format, line, mixer);
}
public void captureAudio() {}
try {}
format = getFormat();
MixerInfo [] Mixer.Info = AudioSystem.getMixerInfo ();
DataLine.info get information on line.
DataLine.Info info = new DataLine.Info (TargetDataLine.class, format);
Drummer mixer = AudioSystem.getMixer(mixerInfo[3]);
Download the info from the desired line.
line = (TargetDataLine) AudioSystem.getLine (info);
Get a TargetDataLine on selected mixer.
line = mixer.getLine (info) (TargetDataLine);
Line.Open (format);
Line.Start ();
CaptureThread captureThread = new CaptureThread();
captureThread.start ();
} catch (Exception e) {}
System.out.println (e);
System.Exit (0);
} //end wrestling
}But now i have a problem in the class Application, because i want to start the capture when i click in the button so i created the actionPerfomed and inside of this event i create this:
Microphone1 m1 = new Microphone1 (format, line, mixer);
M1.captureAudio ();But when i execute the application and click in the button appears this: java.lang.NullPointerException :/ and i don't know how to solve this.
Any help? Where i am wrong?
Well Yes, see also http://download.oracle.com/javase/tutorial/java/index.html
Tags: Java
Similar Questions
-
We encountered the following problems: creative cloud desktop cannot be installed. (Error code: 1).
-
fingerprint sensor does not work for my iphone 16 6 GB pls help how to solve this problem?
I have iPhone 6 grey 16 GB of model space suddenly my fingerprint sensor no longer works.
When I try to set touch id always displays "failed please go back and try again".
Please guide how to solve this problem.
The warranty expired 3 months ago
See this support document to help solving the problems of contact ID. If all else fails, then make an appointment at the Genius Bar from the Apple Store supplier or Service Center authorized Apple closest to have the material examined. They will explain your options. Use touch on iPhone and iPad - Apple Support ID
-
Anyone know how to solve my problem? I can't import my photos from Iphone to computer. Sign says: Photos in the camera cannot be imported because the IPhone is locked with a password or read. My phone is unlocked. I tried everything, every single idea. Without success! Any other idea?
For example, you specify that the device does not display the lock screen, correct? Do you use Touch IDS? If so, try to put your finger on the device to see if it's what he wants.
See you soon,.
GB
-
My mac does not detect my hard drive after the upgrade. How to solve this problem?
My mac does not detect my hard drive after upgrading to Mac OS Sierra. How to solve this problem?
Please provide more detailed information. You can read write an effective communities of Apple support question. Maybe you could open disk utility and take a screen snap so that we can see what you see.
To post a screenshot
- Press command + shift + 4, that will change the cursor to the line of sight.
- Hold down the mouse button and the collimator allows you to select the part of the screen you want to capture.
- Release the mouse button and the image will be saved on your desktop.
- Click on the camera icon in the toolbar of the message forum Editor.
- Drag the image on the button select a file and click the Insert button.
-
I'm trying to access an online simulation via MyMIS Lab of Pearson for a class online. I was using this simulation a couple of days, but when I logged on this morning, the simulation does not open. I copy and paste the error message that appears when I try to open it. Basically, it reads "you see this error because you have DEBUG = True in your file settings to Django. Change False and Django will display a 500 standard page. I have no idea what Django settings are and have studied how to change the setting, but I'm not familiar with this at all. Any help would be greatly appreciated so I can get my homework done! Thank you!!!
AttributeError at /simLaunch/launch/
'Settings' object has no attribute 'XLSIMS_LAUNCH_URL'
Request Method: POST
Request URL: http://econdip.pearsoncmg.com/xlsim/simLaunch/launch/
Django Version: 1.5.2
Exception Type: AttributeError
Exception Value:
'Settings' object has no attribute 'XLSIMS_LAUNCH_URL'
Exception Location: /vh/docroots/econdip.pearsoncmg.com/prod/virtualenv/lib/python2.6/site-packages/django/conf/__init__.py in __getattr__, line 54
Python Executable: /usr/bin/python
Python Version: 2.6.6
Python Path:
['/vh/docroots/econdip.pearsoncmg.com/prod/virtualenv/lib/python2.6/site-packages',
'/usr/lib64/python26.zip',
'/usr/lib64/python2.6',
'/usr/lib64/python2.6/plat-linux2',
'/usr/lib64/python2.6/lib-tk',
'/usr/lib64/python2.6/lib-old',
'/usr/lib64/python2.6/lib-dynload',
'/usr/lib64/python2.6/site-packages',
'/usr/lib64/python2.6/site-packages/gtk-2.0',
'/usr/lib/python2.6/site-packages',
'/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg-info',
'/vh/docroots/econdip.pearsoncmg.com/prod/server/glservice']
Server time: Sat, 30 Aug 2014 14:59:46 -0500
Environment:
Request Method: POST
Request URL: http://econdip.pearsoncmg.com/xlsim/simLaunch/launch/
Django Version: 1.5.2
Python Version: 2.6.6
Installed Applications:
('django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'gldata',
'econ.ca',
'econ.ue',
'gllaunch',
'datacapture',
'xlsims')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')
Traceback:
File "/vh/docroots/econdip.pearsoncmg.com/prod/virtualenv/lib/python2.6/site-packages/django/core/handlers/base.py" in get_response
115. response = callback(request, *callback_args, **callback_kwargs)
File "/vh/docroots/econdip.pearsoncmg.com/prod/virtualenv/lib/python2.6/site-packages/django/views/decorators/csrf.py" in wrapped_view
77. return view_func(*args, **kwargs)
File "/vh/docroots/econdip.pearsoncmg.com/prod/server/glservice/xlsims/views.py" in launchSim
23. if TPIUtils.has_valid_signature(launch_data, url=settings.XLSIMS_LAUNCH_URL, key='bphsc2014'):
File "/vh/docroots/econdip.pearsoncmg.com/prod/virtualenv/lib/python2.6/site-packages/django/conf/__init__.py" in __getattr__
54. return getattr(self._wrapped, name)
It's a problem with a Python script that runs on the server.
The site Web needs to solve this problem.
If the problem persists then contact them by e-mail.
You can try to clear the cache and delete cookies from this Web site.
"Clear the Cache":
- Firefox > Preferences > advanced > network > content caching Web: 'clear now '.
'Delete Cookies' sites causing problems:
- Firefox > Preferences > privacy > "Use the custom settings for history" > Cookies: "show the Cookies".
-
My Macbook Air uses El Capitan 10.11.5. This operating system repeatedly freezes and the computer must be turned on / repeatedly. How to solve this problem?
Hello
Check if the hard disk needs repair.
Open the disk utility, located app in HD > Applications > utilities
Select Macintosh HD on the left then click the first aid tab, and then click Run.
-
Sent items from MS outlook do not appear in Thunderbird, but it works in the reverse (envoys since Thunderbird appears in Outlook). How to solve this problem?
I guess you have a pre existing account using the POP Protocol, that not only downloads the contents of the Inbox.
Hotmail, Live, MSN, Outlook dot com now support IMAP which is a synchronized messaging service, changes in one are reflected in the other.
File menu (alt + F) > New > existing e-mail account and add your account to the Thunderbird again. Make sure you have "account type selected IMAP and your all synchronized will.
If it's like my account, your IMAP e-mail account will come with a subfolder under the pop called deleted folder that contains all mail I have downloaded in the past years.
If you right-click your \new IMAP account in the folders pane on the right immediately after you create it and choose to subscribe you can unsubscribe from this folder if you don't see it
-
Updated macbook pro today for the latest version of el capitan and now will not start. Instead, I get the error message "your computer restarted due to a problem". Someone at - it suggestions on how to solve this problem?
It would be helpful to post what the screen says.
-Try to reset memory NVRAM/PRAM and SMC
MacIntel: Reset of the controller (SMC) system management
https://support.Apple.com/en-us/HT201295
Subject of memory NVRAM and PRAM
https://support.Apple.com/en-us/HT204063
-Try to start safe mode
OS x: what is Safe Boot, Safe Mode?
https://support.Apple.com/en-us/HT201262
-Start to recovery and repair the startup disk
OS X: on OS X Recovery - Apple Support
https://support.Apple.com/en-us/HT201314
-If it is repairable reinstall the OSX
How to reinstall OS X on your Mac - Apple Support
https://support.Apple.com/en-us/HT204904
-If you do not have a backup using disk utility to restore the internal drive to an external drive, so that you can try to recover the data.
-
Firefox remembers the story, but doesn't remember the closed tabs, sessions.
It happened after the Fox update to v. 19.0.2 on a single computer.
In Options of Firefox is set to use Custom Settings For History, everything is checked except always use Private Browsing Mode. So I'm not in private browsing.
When I press to Undo Closed button nothing happens, & in the Manager session Save Session button is grayed. I tried to install other add-ons that remembers the tabs. tried to reinstall/disable these 2 modules. Did ' t help. On my 2nd computer I have same modules, same settings and they work normally. the 3rd closed computer undo works tabs also. How to solve this problem? I decided to ask before Firefox Reset...
----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Sync is a separate issue. It works, but quite often it connects me sync account. Then I can connect only using the recovery key password and long (option choice I have no device with me because he does not accept the key to pairing device).
Thanks for reading.
In case you use "clear history of Firefox closing:
- do not erase browsing history
- Tools > Options > privacy > Firefox will be: "Use the custom settings for history": [X] clear history of Firefox closing > settings
- https://support.Mozilla.org/KB/clear+recent+history
Note that compensation "Preferences of Site" clears all exceptions for cookies, images, windows pop up, installation of software and passwords.
-
When I run Mozilla Firefox I get the error message "ReferenceError: Globalstorage is not defined." How to solve this problem?
-Vinayak
GlobalStorage is no longer supported in the current Firefox (removed in Firefox 13), versions so the extension or Web site that uses it needs an update and use localStorage instead.
- bug 687579 - Remove support globalStorage
-
I'm unable to delete obsolete email addresses of mail. When I change a card email address Contacts outdated address appears at the top of the queue. Is it a problem of Contacts or a mail problem. How to solve this problem?
Have you tried to go to the recipients of mail/window/previous and delete e-mail addresses it?
-
I have updated to ios 9.3.1 now I have no sound for text messages alerts and alert sounds no calendar! I just missed a meeting disaster. Any ideas how to solve this problem, all the settings are correct.
Try a reset...
Force restart your iPhone: tap on and hold the Home and Sleep/Wake buttons for at least ten seconds, until you see the Apple logo.
If this does not help, tap settings > general > reset > reset all settings
-
Maybe it's a virus problem. Firefox no longer displays its toolbar, even after I download a new version. Only a black space appears where it used to be. I can't change the security or history or other settings. Any ideas how to solve this problem?
- In versions of Firefox 3.6 on Windows and Firefox 4 on Windows and Linux, it is possible to hide the "menu bar" by "view > toolbars" or via the context menu of a toolbar.
- Press F10 or press and hold the Alt key to bring up the 'Menu Bar' temporarily.
- Go on "view > toolbars" or right-click the 'menu bar', or press Alt + V T to select the toolbars to show or hide (click on an entry to switch from the State).
See also:
-
IPhone 5 IOS 9.2 (13 c 75) I can log in my car with Blue Tooth to make phone calls, but it does not connect to the speaker. To establish the connection with the car, the procedure has been completed correctly. With the iPhone 5 it works perfectly correct.
How to solve this problem? Is there someone who has the same problem?
Howdy,
Thank you for using communities Support from Apple.
I see you try to get your iPhone to interface with the stereo in your car via Bluetooth. For setting this up, please follow the steps below.
If you use Bluetooth
- Consult the user manual of your car stereo to get the procedure to a Bluetooth device.
- On your iOS device, drag up to open Control Center, then press ontwice to turn on Bluetooth and turn it back on.
- Restart your iOS device.
- On your iOS device, Cancel the twinning of your car radio. On the screen of your car désapparier your iOS device and any other device. Restart your car and your iOS device, then pair and connect again.
- Update your iOS device.
- Install the updates to the firmware of your car radio.
- If you still not connect, contact Apple technical support.
Help to connect your iPhone, iPad or iPod touch with your car radio
See you soon.
Maybe you are looking for
-
Satellite L50D-C - marketing questions
I've had my Toshiba Satellite L50D-C since October 19, 2015 and almost day 1, I had problems turning on the laptop in standby mode. I press the power button and the led lights as the num snaps and caps lock lights up. The power light stays on as the
-
Portege M700-106: unable to start the task manager & programs after Vista sleep
Hello In fact I am facing problem like below...Configuration: Portege M700-106 with upgrades (Hynix Kingston 4 GB, WD Scorpio 320 GB with jumper default config doesn't = no jumper)Reinstalled system from Toshiba DVD recovery, all updates possible on
-
Re: Satellite L10: cannot use the USB after XP Home recovery
After Systemrecovery with the toshiba CD-ROM and install all updates for xp, there is no chance to use usb on somthething else keys. XP said ' you must intsaller a pilot ", but I do not know whichdriver. I don't think that in 98 I intsaller a driver?
-
If it is not recommended to burn DL iDVD projects?
Hello When I want to save/record an as project DL iDVD project, iDVD says, one should not burn to / save as disc image, if you want to use DL media. Here, he also says that most stand-alone players will not play DL media http://www.peachpit.com/artic
-
transfer the app from iphone to itunes library
Hello world. I have an ios application that are not re - download in the app store specifically TUBE DOWNLOADER (D/L) by Apps2be. I don't know why this particular application has been removed in my itunes library. I got a new Ipad pro and I want t