• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

Weird Error

 
Greenhorn
Posts: 12
Eclipse IDE Python Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

This Java is really weird. My compiler recognizes that Javax.sound is a valid type/object(Not sure which!) The problem is it doesnt recognize Sequencer, Sequence, MidiSystem.getSequencer(). It treats createTrack() as a variable too. Help!
 
Bartender
Posts: 2911
150
Google Web Toolkit Eclipse IDE Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nathan, Welcome to code ranch

I think your program misses a few imports:


what is "track" ? do you mean "javax.sound.midi.Track" ?
 
salvin francis
Bartender
Posts: 2911
150
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your code is missing "timing" and "myMidiEvent" variables. I find "rand" as a very weird name, what does it imply ? Does it have something to do with sound ?
Next time, I suggest you can paste the compile error so that we can help you better.
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
suppose using a wild card with a Java import statement is not best practice.  this post  http://www.fredosaurus.com/notes-java/language/10basics/import.html have good explanation of certain options with imports.

 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Note that when you import things with a wildcard *, then you are not importing whatever is in subpackages. So, import javax.sound.* does not import the classes in javax.sound.midi, for example - only classes in the package javax.sound itself.
 
Nathan Tibbitts
Greenhorn
Posts: 12
Eclipse IDE Python Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I did all the things, now the only error is
 
Jesper de Jong
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you wonder what a specific exception means exactly, then you can lookup its API documentation: javax.sound.midi.InvalidMidiDataException

This is probably happening because the value of the variable timing (the parameter divisionType) in line 6 of your code is not correct:

The API documentation of the constructor of class Sequence that you are using says:

API documentation wrote:
Constructs a new MIDI sequence with the specified timing division type and timing resolution. The division type must be one of the recognized MIDI timing types.
...
Throws:
InvalidMidiDataException - if divisionType is not valid


This means that the value of the first parameter that you pass to the constructor must be one of the constants declared in class Sequence: PPQ, SMPTE_24, SMPTE_25, SMPTE_30DROP, SMPTE_30

What is the variable timing, and what is its value? You haven't declared it in the code that you posted above, so your code doesn't compile.
 
In the renaissance, how big were the dinosaurs? Did you have tiny ads?
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic