Why Doesn't my midi player work

//  MusicBox.java
//  sachs
//  Created by David Kopec on Mon Jul 14 2003.
//  Copyright (c) 2003 __MyCompanyName__. All rights reserved.
import javax.sound.midi.*;
import java.net.*;
import java.io.*;
import java.util.*;
public class MusicBox implements MetaEventListener, Runnable  {
    private String[] names;
    private boolean continuing;
    private Sequence sequence;
    private Sequencer sequencer;
    private Random r;
    public MusicBox(String[] ns, boolean c){
        names = ns;
        continuing = c;
        Random r = new Random();
        try{
            sequencer = MidiSystem.getSequencer();
            sequencer.open();
            sequencer.addMetaEventListener(this);
        catch (Exception e){
            e.printStackTrace();
        Thread t = new Thread(this);
    public void playRandom(){
        try{
            URL u;
            u = getClass().getResource(names[r.nextInt(names.length)]);
            sequence = MidiSystem.getSequence(u);
            sequencer.setSequence(sequence);
            sequencer.start();
        catch(Exception e){
            e.printStackTrace();
    public void run(){
        playRandom();
    //implement metaEventListener
    public void meta(MetaMessage event) {
        Thread t;
        if (event.getType() == 47) {
            // Sequencer is done playing
            if (continuing)
                t = new Thread(this);
    //clean up
    public void finalize() throws Throwable{
        sequencer.close();
        super.finalize();
}Any ideas? It's just silent.

Seems to me, you have not attached any receiver to the sequencer's transmitter. How a sequencer will generate a sound, it is required to be attaced to a Synthesizer. Try do something like following in your starting code:
try {
sequencer = MidiSystem.getSequencer();
sequencer.open();
sequencer.addMetaEventListener(this);
// similarly you have to obtain a synthesizer
synthesizer = MidiSystem.getSynthesizer();
synthesizer.open();
// now wire a synthesizer to a sequencer
sequencer.getTransmitter().setReceiver(synthesizer.getReceiver());
} catch (Exception e) {
e.printStackTrace();
Regards.

Similar Messages

  • Why doesn't my flash player work?

    I installed the Flash Player from Adobe, the message said it was successful. When it went to the Adobe page, it went black. I checked the control panel and it showed it as installed. When I tried it on Jib Jab, I could not see the video. It works on Google Chrome but not on Internet Explorer. I upgraded to IE 10 and that did not help either. I checked Norton and shut off the Antivirus, then did the Adobe debugging, and tried several times. Nothing seems to work. It seems like it installs but does not initiate.

    Did you copy and paste that from your response in '08? Or maybe it was '07?
    I wonder if I could apply this to other technologies...
    Radio after tv invention:
    The drop in Radio only programs, and increase in TV shows in such a short period of time has been staggering. As other programs move on without Radio, since it's signal band is no longer being updated, it will become something akin to the telegraph...if it hasn't already.
    Boats after car invention:
    The drop in Boat only shipping, and increase in shipping methods that are vehicle friendly in such a short period of time has been staggering. As other companies move on without boats, since they are no longer building new channels, it will become something akin to the horse and buggy...if it hasn't already.
    etc etc...
    See you in 6 more years.

  • Why doesn't my media player work

    media on my laptop dosen;t work

    Seems to me, you have not attached any receiver to the sequencer's transmitter. How a sequencer will generate a sound, it is required to be attaced to a Synthesizer. Try do something like following in your starting code:
    try {
    sequencer = MidiSystem.getSequencer();
    sequencer.open();
    sequencer.addMetaEventListener(this);
    // similarly you have to obtain a synthesizer
    synthesizer = MidiSystem.getSynthesizer();
    synthesizer.open();
    // now wire a synthesizer to a sequencer
    sequencer.getTransmitter().setReceiver(synthesizer.getReceiver());
    } catch (Exception e) {
    e.printStackTrace();
    Regards.

  • Why Doesn't the XIRR function work?

    In Excel if you have 5 records from a1:b5 then XIRR looks like this:
    XIRR(A1:A5, B1:B5) you get a nice neat answer like .35
    Here is a version that works in Crystal that would require manual entry of any new quarters numbers and dates-- and if you plug this into Crystal it works:
    (XIRR([1000000,-100000,-100000,-100000,-100000,10277.49,-100000], [DateValue(1999,2,1),DateValue(1999,3,1),DateValue(1999,6,1), DateValue(1999,12,1),DateValue(2000,3,1),DateValue(2000,6,1),DateValue(2000,9,1)]))*.100
    You do get a nice answer of something like .035.  But this is all done manually and I need it to function automatically when the report is refreshed.
    So you have a range for the currency and a range for the date fields. I need to simulate this in crystal. Crystal has an XIRR function, and with the arrays, I should be able to fill in the range, but am having difficulty getting it to work.
    After building the arrays, I made another formula to combine the arrays in the XIRR formula.
    I am down to this error now after getting this formula this far  --
    "Numerical method did not converge; try another value for guess."
    Here's where I am with the formula, although they don't want to use the guess part of the XIRR function - they just want to use the XIRR(number/currency, date).  Maybe you could pass this on too?:
    /{@Reset} for the group header (NOT using a repeated group header):
    whileprintingrecords;
    numbervar array x := 0;
    datevar array y := date(0,0,0);
    numbervar i := 0;
    numbervar j := 0;
    //{@accum} for the detail section:
    whileprintingrecords;
    numbervar array x;
    datevar array y;
    numbervar i := i + 1;
    numbervar j := count({table.groupfield},{table.groupfield});
    if i <= j then (
    redim preserve x[j];
    redim preserve y[j];
    x<i> := tonumber({table.currency});
    y<i> := datevalue({table.datetime})
    //{@xirr calc} to be placed in the group footer:
    whileprintingrecords;
    numbervar array x;
    datevar array y;
    xirr(x,y)
    The array works correctly.  So why do I get that error and why doesn't the XIRR formula work like they say it should?  Has anyone used this successfully in Crystal--maybe you could shed some light?
    Thanks!

    Hi,
    I am receiving that same error when the last item in the array is 0, otherwise all works perfectly.
    When I run the same group of numbers and dates in Excel it returns without issue.
    -265500.00,-690000.00,-570000.00,16814.25,-855000.00,-619500.00,55293.46,30411.40,15183.76,  0.00
    01-25-2007,03-06-2007,05-02-2007,06-29-2007,08-01-2007,08-24-2007,09-17-2007,03-14-2008,05-28-2008,03-31-2010
    =XIRR(A2:J2,A1:J1,-0.1)
    Is there a known bug in Crystal's XIRR function when the last value is 0? 
    Or a hot-fix that will repair this?
    Thanks in advance,
    Gary
    PS. I am using Crystal XI Product Version: 11.0.0.2495

  • Why doesn,t  my mail iccon work?

    Why doesn't my mail icon work?

    If you moved Mail out of the Applications folder, then applied the security update, Mail has been disabled.
    It must stay protected in the Applications folder, or you risk the possibility that malware might change it and use it to send spam.
    Mac OS X v10.6: "You can't use this version of Mail…" alert after installing Security Update 2012-004

  • Why doesn't the "back" button work all the time in Safari?

    Why doesn't the "back" button work all the time in Safari?

    thanks for the reply. You prompted me to check and I realised it wasn't installed on my test laptop and opening in Microsoft Reader. I've installed it now and it works.
    My next challenge is to prevent the mailto: command opening Microsoft Mail instead of Outlook, but I guess every user will have a different default.
    Thank you

  • Why doesn't my VGA adapter work to connect my iPad2 to my projector. I haven't had any problems in the past?

    Why doesn't my VGA adapter work to connect my iPad2 to my projector. I haven't had any problems in the past?

    Hey MarieF-D,
    Thanks for the question. The following article provides basic troubleshooting steps that may help to resolve your issue:
    iOS: About Apple Digital AV Adapters
    http://support.apple.com/kb/HT4108
    Troubleshooting
    If you encounter an issue using the Apple Digital AV Adapter or VGA Adapter:
    Disconnect and reconnect the adapter from the iOS device and display.
    Connect directly to the TV, projector, or external display using a known-good VGA or HDMI cable.
    Remove any VGA or HDMI extension cables or converters.
    Note that accessories that convert a VGA or HDMI signal to other video formats (DVI, Composite, Component) are not supported.
    Ensure that you are using the latest version of iOS. Some Apple Digital AV Adapters require iOS 5.1 or later.
    Note: When using an Apple Digital AV Adapter manufactured before early 2012 with iPad (3rd generation), you may see the "This accessory is not supported" alert. Dismissing the alert will allow you to use the adapter.
    For optimal performance, you may need to adjust the video resolution or settings for your display. If your display offers an "auto detect" or "factory default" setting, you may be able to use these options to optimize video resolution and display.
    Thanks,
    Matt M.

  • Lost my iPhone and why doesn't find my iPhone work

    Lost my iPhone and why doesn't find my iPhone work

    A friendly reminder: In order to use Find My IPhone Successfully, you need to 1. Turn on Location Services, 2. Lock Location Services (Using Restrictions in Settings, General, Restrictions) so that if some one else finds your IPhone, they can NOT turn off Find My IPhone And/Or Location Services itself! 3. Add your Mobile Me and/Or ICloud Account to your IPhone. 4. Lock Accounts (Again in Restrictions) from being changed or Deleted so that your Mobile Me And/OR ICloud Account can NOT be Deleted! 5. Look Up the Location of your IPhone Before Suspending Service to the IPhone, NOT after Suspending Service (simple common since applies here as well).

  • Why doesn't my duplicate frame work in photoshop 2014?

    why doesn't my duplicate frame work in photoshop 2014?
    I draw a figure in frame 0 then duplicate frame. After the frame is duplicated I move the figure over to make sure there are different frames but as soon as I check the first frame Ive noticed that both frames have moved together. So nothing has changed. Why?

    I always create the individual frames in layer groups first. So build what you need, break them up or duplicate them, position them where you want them and then create your frames by turning off all the layer groups or layers you don't need.
    Here is an example of one of my layer pallets:
    Each scene is a frame and I turn them on and off as I need them.

  • Why doesn't my email address work for apps

    Why doesn't my email address work on my envy printer?

    You don't give us anything like enough data to go on. What is your operating system? Do you have a functioning iCloud account - i.e. are you signed in in System Preferences>iCloud?
    Were you originally a MobileMe subscriber? If so, did you migrate to iCloud?
    Was your email still working recently? Do you get any error messages? What happens when you try to use it?
    Have you been using an @icloud.com address or an @me.com address?
    (Please do not post your email address when answering.)

  • Why doesn't my iWeb page work with google chrome?

    Why doesn't my iWeb page work with google chrome?

    Bonjour
    Don't test your website with Google Chrome if you publish it into a local  folder.
    Publish to a server. You need an URL with http:// and ( not file://) to view an iWeb site in Chrome.
    You can also
    activate the web sharing on your computer (Preferences system > Sharing > Check web sharing)
    publish to Sites folder (MacIntosh HD > Users > Home folder >Sites)
    and use the URL (with http) given by the web sharing tab in preferences system http://computer_name.home/~user_name/site_name/

  • Why doesn't the CC app work properly?

    I've been using Creative Cloud for some time now and am really loving it, however I must say it is a source of annoyance that the Creative Cloud app just doesn't work properly.
    Firstly, I used it initially to download all my apps, then after an update those apps no longer appeared in the "Apps" list. Now only those that have been installed since that update appear in this list. Why doesn't the "Apps" list display all of the Adobe CC apps that I have installed on my computer?
    Why does it keep reinstalling fonts? I'm always getting "Lush Script Regular" and other fonts being added.
    It regularly comes up telling me that Dreamweaver and Premiere Pro need to be updated, but always I get an error, then the update request disappears.
    I'm regularly getting 4 files that it can't sync - even though they are the same files as others in the folder. If nothing else, why can't I say "Great, got the message". Also, why is the error message just "due to server error" with no advice on how to resolve it? Why is there a server error on only these 4 files?
    It seems to me there are still some teething issues with the CC app, but what I don't understand is why they aren't being resolved much faster, given that this is the portal to the service.
    Of course, given Adobe I doubt I'll get satisfactory answers – a little jaded with their responses. Anyway, thought I'd at least post the questions.  

    Questapo I am sorry you have been facing difficulties with your Creative Cloud experience.  I don't believe it will be possible to address all of your concerns in one discussion.  I would not be surprised if at least three of the issues are related to the same root cause.
    First in order for the applications to be visible are you regularly needing to delete the OPM.db file?  You can find this listed as solution 2 in CC desktop lists applications as "Up to Date" when not installed - http://helpx.adobe.com/creative-cloud/kb/aam-lists-removed-apps-date.html.

  • Why doesn't my audio input work?

    I have a Macbook with OS X and have never been able to get an external microphone to produce sound on the computer. I was using an old pair of headphones but the brand new pair I bought also do not produce any sound. They are the basic headphones with a mic attached and plug into the Macbook using two mini-plugs in the two audio ports (one for input, one for output). I can hear sounds in the headphones just fine. But I'm only able to talk if I use the internal microphone on the Macbook, which is inconvenient as it picks up too much background noise. I'd rather use the external mic.
    When I got into my preferences > sound > input, there are two choices there:
    Internal microphone -- type: Built-In
    Line In -- type: Audio Line-in Port
    I select the second option and nothing works. Am I missing something here?

    Well, FWIW, I did a lot of searching on here and it seems that this type of basic, unpowered mic will not work with my Macbook Pro (OS 10.7.5) and that any audio input has to be powered in some way -- a cd player for example that provides a powered signal into a pair of headphones or into the computer. I bought one of those very basic $15 headsets with microphone from Wal-Mart. Two different brands failed to produce any sound. (though the sound OUTPUT to the headphones works just fine)
    Oddly enough, I did call Apple Tech Support and they were confused and unaware of why the headset' mic shouldn't work just fine. So apparently, this is not a "known" issue. So I'm just going to pay a little more and go buy a Bluetooth or USB headset.

  • Why doesn't my default email work?

    Hey Ya'll,
    Quick question if anyone can help. I have a new MacBookPro, and LOVE it. My email was working great, but as soon as my free trial of .mac expired, I can't get my default email from my non-.mac account. Why doesn't it work and what do I do to get it working?
    Alisa

    Launch Mail and select preferences and reset your mail app to Mail. If you were using web-based mail with the trial .Mac account, I don't know if any of that's recoverable. Check the .Mac forum.

  • Why doesn't my create pack work?

    Why doesn't my create pack do anything that I need it to do.  Can't save to pdf, can't retrieve, doesn't recognize format.  The free trial version worked; the subscription does not.

    If you moved Mail out of the Applications folder, then applied the security update, Mail has been disabled.
    It must stay protected in the Applications folder, or you risk the possibility that malware might change it and use it to send spam.
    Mac OS X v10.6: "You can't use this version of Mail…" alert after installing Security Update 2012-004

Maybe you are looking for

  • Is there any way to send a short video by mail?

    I am trying to make an interactive PDF with 3 short videos and sound as a Halloween card. It is too large to go through email and when I try to read it on an ipad with Adobe Reader, the videos do not play. What would be the best way to send something

  • "Could not determine code page" inbound side error

    Guys, We are receiving a flat text file and sending an IDoc, but now I'm getting this error. Any idea what's wrong? And what is that "I::000" in the message? Any help is much appreciated. Thanks a lot, Viktor   <?xml version="1.0" encoding="UTF-8" st

  • HT1920 forgotten security questions

    I have forgotten the answers to my security questions how do I recover them. Im trying to make a purchase after rebooting my pc and apple dosnt reconize my pc

  • How does one tie DBA_HIST_SQLBIND to DBA_HIST_SQL_PLAN?

    Since DBA_HIST_SQLBIND seems to associate a bind variable with a particular sql_id of a snap_id, I am finding it hard to locate the correct query plan for a query that has multiple hash plan values. Or, if you have a better way of doing this, I am al

  • Product Announcement: ATM Light 4.1 Now Posted

    Hello - ATM Light 4.1 for Windows has just been posted on the adobe.com web site for free download. If you do not require the font management features that ATM Deluxe supplies, then this is the download you need. Note, the file size is about 12.7 meg