Manually edit volume of MIDI file in Java

Hey all, I'm trying to find a way to manually change the volume (velocity) of a midi file before playback, i.e. directly in the code. This is the code I'm using to play my midi files:
import javax.sound.midi.*;
import java.io.*;
/** Plays a midi file provided on command line */
public class MidiPlayer {
public static void main(String args[]) {
try {
// From file
Sequence sequence = MidiSystem.getSequence(new File("C:\\Sounds\\twinkleaccomp.mid"));
// Create a sequencer for the sequence
Sequencer sequencer = MidiSystem.getSequencer();
sequencer.open();
sequencer.setSequence(sequence);
// Start playing
sequencer.start();
} catch (IOException e) {
} catch (MidiUnavailableException e) {
} catch (InvalidMidiDataException e) {
How can I edit my code so that I can easily change the midi file's volume before I run and compile the code?
Thank you, any help will be appreciated!
PS: Sorry about the twin topics!

Ravaa wrote:
Hey all, I'm trying to find a way to manually change the volume (velocity) of a midi file before playback, i.e. directly in the code. This is the code I'm using to play my midi files:
Thank you, any help will be appreciated!Gosh, I've looked through all of the MIDI references I have, and nothing talks about setting the MIDI file volume...probably because the velocity is set on each individual MIDIEvent...
My best guess as to how to set the global volume for a MIDI file would be to loop through all of the MIDI events in the file and modify their velocities individually...that's the only thing I can come up with.

Similar Messages

  • Why even unchecked my crash reports are sent? I have to manually edit the "application.ini" file at every update! This is unacceptable to the user's choice!

    Why even unchecked my crash reports are sent? I have to manually edit the 'application.ini' file at every updates! This is unacceptable for the user's choice!

    Check the SubmitCrashReport (DWORD) key in the registry and set the value to 0.
    *HKEY_LOCAL_MACHINE\Software\Mozilla\Firefox\Crash Reporter\SubmitCrashReport: DWORD
    *HKEY_CURRENT_USER\Software\Mozilla\Firefox\Crash Reporter\SubmitCrashReport: DWORD
    You may need to check the HKLM\Software\Wow6432Node\ node on 64 bit Windows.
    *http://kb.mozillazine.org/Mozilla_Crash_Reporter

  • Manually Edit An Alias Original File Path?

    How do I edit the original path that an alias uses?
    I have created an alias to a network volume, but the patch that the alias is using is by share name (/Volumes/Share Name) whereas I want it to use the ip (/192.168.2.5/folder).
    However, I can't figure out how to manually edit the alias path. Once upon a time the "Select new original" dialoge box had a "Go to:" line where you could manually enter a path but in 10.4 it is gone).
    Any help would be much appreciated.
    Message was edited by: Cobber 99

    Well, you could do a couple of things. You could place the .afplocs files somewhere in the hard drive (e.g.: /Documents/afploc_folder) and then place aliases to those .afplocs in the doc (just drag them to the Dock from the Finder). You can even assign them custom names and icons through Get Info.
    Another option would be save the .afploc file, and then select the original alias you wanted to modify, and assign it the .afploc as new original through Get Info.
    Both these methods provide you with a clickable dock icon, that will connect to the volume.
    I vaguely remember about a BSD command called mkalias that creatd aliases from the command line rather than from the Finder, but have no details on that. Maybe you should do a little research about it.
    Good Luck.

  • Any Complete Tutorials On How To Edit And Export MIDI Files In GB?

    Hi. A friend sent me about 25 nice standard MIDI files that all open fine in QT Pro. She wants me to drag and drop them into GarageBand 2, attempt to edit them, change sounds and then export them out as the edited versions, key changes, added bars, change instrument sounds, etc,. Although I'm a trained musician who understands form, I really don't have a clue on how to use GB to edit and export standard MIDI files. Can this be done effectively in GB ver 2 or 3?
    Basically what she then wants to do is take the edited MIDI tracks, put them into itunes I guess on her iBook G4 or Ipod and do a solo act playing her keyboard live and usibg the MIDI tracks as background.
    Are there any links to step by step tutorials on how I can lerarn this procedure? Please offer any advice and links if you can and thanks for your help
    steveb

    Not really practical, I'm afraid. Capturing screenshots and cutting them up is possible with Photoshop, but PDF editing is very limited (fix a typo, move a picture).

  • Reading/editing/writing midi files

    Hi,
    does anyone experienced how to read, edit and write midi file back to the JAR file with J2ME /MIDP 2.0? All I can do is playing the file, that's not much and not what I need :-(
    Thanks

    There are no built in methods in MIDP to edit MIDI files. If you know the format well enough, you can read the file into a byte array (using Class.getResourceAsStream()) and edit it manually byte by byte. You won't be able to write it back to the jar, but you can save the edited MIDI in the RMS, or if you have one of the newest phones that support file connections then you can save it on the phone's file system.
    shmoove

  • Extracting data content of a midi file

    I am trying to build an application to compare midi files and establish some form of pattern using their data contents(txt).
    i'll like to see a source code on the extraction of the data content of midi files using java classes.

    Don't really know but I'm sure you'd find something here:
    http://java.sun.com/products/java-media/sound/

  • How to create and edit a .ini file using java

    Hi All...
    Pls help me in creating and editing an .ini file using java...
    thanks in advance
    Regards,
    sathya

    Let's assume the ini file is a mapping type storage (key=value) so lets use Properties object. (works with java 1.4 & up)
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.util.Properties;
    public class Test {
         private static Properties props;
         public static void main(String[] args) throws IOException {
              File file = new File("test.ini");//This is out ini file
              props = new Properties();//Create the properties object
              read(file);//Read the ini file
              //Once we've populated the Properties object. set/add a property using the setProperty() method.
              props.setProperty("testing", "value");
              write(file);//Write to ini file
         public static void read(File file) throws IOException {
              FileInputStream fis = new FileInputStream(file);//Create a FileInputStream
              props.load(fis);//load the ini to the Properties file
              fis.close();//close
         public static void write(File file) throws IOException {
              FileOutputStream fos = new FileOutputStream(file);//Create a FileOutputStream
              props.store(fos, "");//write the Properties object values to our ini file
              fos.close();//close
    }

  • How to edit the existing data in the XML file from java programming.

    Hi all
    i am able to create XML file with the sample data as below from java programming.
    i need sample code on how to edit the existing data in the XML file?
    for example
    <?xml version="1.0"?>
       <mydata>
               <data1>
                         <key1>467</key1>
                        <name1>Paul</name1>
                        <id1>123</id1>
              </data1>
              <data2>
                         <key2>467</key2>
                        <name2>Paul</name2>
                        <id2>123</id2>
              </data2>
        </mydata>
    i am able to insert the data in the XML.
    now i need sample code on how to modify the data in the above XML file from the java programming for only key2,name2,id2 tags only. the remaining tags data in the XML file i want to keep same data except for key2,name2,id2 which are i want to modify from java code
    Regards
    Sunil
    [points will be always rewardable]

    hi
    u need a parser or validate the xml file for to read the xml file from java coding u need for this
    xml4j.jar u can download this file  from here
    http://www.alphaworks.ibm.com/tech/xml4j
    or we can use the SAX(simple API for XML)
    some sample applications for this
    http://www.java-tips.org/java-se-tips/javax.xml.parsers/how-to-read-xml-file-in-java.html
    http://www.developertutorials.com/tutorials/java/read-xml-file-in-java-050611/page1.html
    http://www.xml-training-guide.com/e-xml44.html
    let me know u need any other info
    bvr

  • How to edit/modify a line of a text file using java io

    Hi every body
    I am new 2 java
    I am struck in editing a text file that ends with .dat
    I successfully added,viewed data of the *.dat file.
    but,I cannt edit,delete the lines that i need to do randomly.
    Here is the code i have written.
    import java.io.BufferedReader;
    import java.io.BufferedWriter;
    import java.io.DataInputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    import java.io.FileWriter;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.InputStreamReader;
    import java.io.LineNumberReader;
    import java.io.RandomAccessFile;
    import java.util.ArrayList;
    import java.util.StringTokenizer;
    public class ReadWriteFile {
         String id=null;
         String name=null;
         String dept=null;
         String doj=null;
         String adrss=null;
         public void WriteFile(String Id,String Name,String Dept,String Doj,String Adrss) throws IOException{
              File f=new File("TraineeDetails.dat");
             if(!f.exists()){
             f.createNewFile();
              BufferedWriter bw=new BufferedWriter(new FileWriter("TraineeDetails.dat",true));
              BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
              System.out.print("Enter Id : ");
              Id=br.readLine();
              System.out.print("Enter name : ");
              Name=br.readLine();
              System.out.print("Enter dept : ");
              Dept=br.readLine();
              System.out.print("Enter doj : ");
              Doj=br.readLine();
              System.out.print("Enter adrss : ");
              Adrss=br.readLine();
              bw.write(Id+"::"+Name+"::"+Dept+"::"+Doj+"::"+Adrss+":END:");
              bw.flush();
              bw.newLine();
              bw.close();
         public static void main(String[] args) throws IOException {
              ReadWriteFile rwf=new ReadWriteFile();
              String TID = null;
              String TADRSS = null;
              String TDOJ = null;
              String TNAME = null;
              String TDEPT = null;
              rwf.ReadFile(TID,TNAME,TDEPT,TDOJ,TADRSS);
         public void ReadFile(String Id1,String Name1,String Dept1,String Doj1,String Adrss1) throws IOException{
              BufferedReader br = new BufferedReader(new FileReader("TraineeDetails.dat"));
              String s;
               while((s = br.readLine())!= null)
                 // Create string tokenizer
                    StringTokenizer st =new StringTokenizer(s, "::");
                      System.out.println("----------------------------------------------");
                      System.out.println("| Trainee Id: "+st.nextToken()             +"|");
                      System.out.println("| Trainee Name: "+st.nextToken()           +"|");
                      System.out.println("| Trainee Department:"+st.nextToken()      +"|");
                      System.out.println("| Date of Joining: "+st.nextToken()        +"|");
                      System.out.println("| Trainee Address: "+st.nextToken()        +"|\n");
                      System.out.println("----------------------------------------------");
               // Close file reader
               br.close();
    }     and here is the data i have written
    Trainee.dat*
    111::jain::roads::2-2008::Blore:END:
    123::tim::service::1-2000::delhi:END:
    444::faru::civil::3-2200::sanapur:END:
    555::niv::cse::10-2000::gnagar:END:
    999::linda::mech::6-2001::tnagar:END:
    258::yansi::geo::8-2002::rtnagar:END:
    656::hari::garrage::3-1000::uttarahalli:END:
    888::muni::hr::5-2009::ernakulam:END:
    007::bond::spy::2-1972::america:END:
    0123::landy::games::6-2003::hdp:END:
    678::maddy::pumbing::4-1999::dispur:END:

    kalanidhi2u wrote:
    I want to randomly access the file
    But i cannt access itmake it RandomAccessFile... RandomAccessFile
    I edited it
    but i cannt edit the file by using itBoth of these are contradictory.

  • Editing a midi file in GarageBand 09

    Just downloaded a midi soundtrack, a karaoke version of a popular song. I plan to track in original vocals, but I have additional verses of lyrics that will require repeating sections of verse and chorus to accommodate.
    As cool as midi is on Garageband, it don't see those (GB file) cleavage points that can be grabbed and manipulated.
    Is there an app that will allow me to convert the midi file into a standard GB file I can work with, or a way to section the midi track for looping and/or repeating in GB?
    At a complete stand still on this;-(

    Good to know. I will have to contact the MP3 site, because I don't see a tempo designation in the limited documentation. I do have the option to download the same song, but in different keys (+/-) 3 half step intervals from the original key the song was done in. Nothing seems happen when I change the key and tempo in Garageband. Another thing I have to dig into.
    Yeh, I was one increment off on my cut point, and when I extended the song, there was a slight audible disassociation at the join points. I'm still curious about monitoring capability when paused, with respect to dragging the tape head line manually and listening to the audio around the cut point or should I say split point.
    The song is set up: intro-verse-verse-chorus-verse-verse-chorus-instrumental break-verse-verse-chorus-verse-verse-chorus-instrumental break-verse-verse-chorus-verse-verse-chorus....ending.
    If I were to just delete the ending, and then grab the last chorus and pull (stretch) the whole track it to the right, what part of the song is expanding? I tried doing this, but the pattern became altered, forcing me to sing through an instrumental break, to keep the vocal coherent.
    I should have copied the section, after the intro and before the ending, and added that, between the body and the ending. I'll try that tomorrow:-)

  • I'm trying to play MIDI files in Quicktime. It works buy the volume is very low, even with both Quicktime and computer volume on max. What can I do?

    I'm trying to play MIDI files in Quicktime. It works buy the volume is very low, even with both Quicktime and computer volume on max. What can I do?

    I'm having the same issue.  After opening Audio Midi Setup in Utilities I noticed that the master volume slider of the Built-In Output is very low.  I am not able to slide to get any more level out of the system.
    Can you adjust the master volume on your system?

  • How to compare and edit Resource bundle file using java programe

    Hi All
    I have two resource bundle with key, value and some comments. I need to write a java code to compare both of the values of the keys and if the values are different then i want to replace the second value with the first value.
    Its a programe which will udpate the second file with the first file values.
    I tried using Properties class but it didnt worked because when i am saving the file using store method it removes all the comments and the order of text also got disturbed.
    How I need to do this any help appriciated.
    Please elt me know if someone needs more info.
    Thanks in advance.

    Let's assume the ini file is a mapping type storage (key=value) so lets use Properties object. (works with java 1.4 & up)
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.util.Properties;
    public class Test {
         private static Properties props;
         public static void main(String[] args) throws IOException {
              File file = new File("test.ini");//This is out ini file
              props = new Properties();//Create the properties object
              read(file);//Read the ini file
              //Once we've populated the Properties object. set/add a property using the setProperty() method.
              props.setProperty("testing", "value");
              write(file);//Write to ini file
         public static void read(File file) throws IOException {
              FileInputStream fis = new FileInputStream(file);//Create a FileInputStream
              props.load(fis);//load the ini to the Properties file
              fis.close();//close
         public static void write(File file) throws IOException {
              FileOutputStream fos = new FileOutputStream(file);//Create a FileOutputStream
              props.store(fos, "");//write the Properties object values to our ini file
              fos.close();//close
    }

  • Volume name of File path / getAbsolutePath, this is driving me insane

    Hello,
    i spent another several hours on this issue i'm having and i think i'm going nuts :=)
    so heres the problem:
    System: Mac OS, two partitions "Mac" and "DATA"
    i have a file "file1.ogg" on the "main" partition (where Mac OS x resides) in the directory tecxx/Music/file1.ogg
    i have a file "file2.ogg" on my NTFS data partition, in the subfolder /DJMUSIC/file2.ogg
    so far, so good.
    when i process these 2 files in my application with a File object and the method "getAbsolutePath()" i get:
    1) /Users/tecx/Music/file1.ogg
    2) /Volumes/DATA/DJMUSIC/file2.ogg
    note that path 1 does not contain any volume name at all, while path 2 contains not just the volume name, but "/Volumes/" in front of the path.
    allright, now here comes the problem. i have another application which uses these 2 files (a dj software). it spits out the filenames of these two tracks in an xml file with these path names:
    1) /Mac/Users/tecxx/Music/file1.ogg
    2) /Data/DJMUSIC/file2.ogg
    Note that this application adds the Volume name to both paths, but NOT /Volumes/.
    what i need to do now is match the filenames against each other. when i process the xml file of the dj app, i extract the filepath, and need to find it in my internal database of my application. but how do i do that, if java returns such strange names, one time without any volume-identifier at all, and the other time with a volume-identifier AND "/Volumes" as a prefx ?
    seriously, this is bugging me for over a week now and i spent the entire day trying to fix this (manually adding "/Volumes/" to the paths, trying different combinations of getAbsolutePath, getCanonicalPath, toURL.toExternalForm; etc,etc), but isn't there an easy solution to get the volume name AND path name of a file somehow?
    in short, i'd like to have a function always return something like this:
    // returns /Mac/somedirectory/somename.ext
    // or        /Data/otherdirectory/someothername.ext
    String getFullPathName(File f)
        return f.getVolumeName() + f.getAbsolutePath();
    }but how do i do the first part (getVolumeName)?
    please help or i will kill myself (just kidding :)
    cheers,
    robert
    Edited by: tecxxtc on May 9, 2008 10:24 AM
    Edited by: tecxxtc on May 9, 2008 10:24 AM

    >
    What program is generating the XML file? What operating system is the third-party software running on?
    I only ask because in my opinion, you should just be working with the absolute pathname, and clearly the third-party app is not doing that.
    >
    traktor dj studio, latest version. it runs either on windows or mac os x. in my case, i run it on windows, but many of my app users run it on mac os x.
    >
    What is the purpose of this application? Is it a script that you're only trying to use on your computer, with your current configuration? Are you trying to distribute it?
    >
    my app has the purpose of managing the song database for traktor dj studio (if you want to take a look.. here's the webpage: http://rrs.at/trakker/ )
    yes, i'm distributing it.
    >
    However, if this is just a script that you want to hack up for yourself, just do some string manipulation on your absolute paths:
    String file = myFile.getAbsolutePath();
    if ( file.startsWith("/Volumes/") {
       //replace "/Volumes" with empty string
    } else {
       //prefix "/Mac"
    }so, this is where i've come to myself. the first part - adding "/volumes/" works fine. but the second part will fail - as i don't know the volume name of the boot partitions of my users. it is not necessarily "/Mac" - thats only true on my own machine :)
    do have a nice idea for me how to solve that?
    i thought about creating a "new File" object for the path i'm reading from the xml, and then iterating my entire "database" of files, creating another "new File" object for each one, and comparing them with "equals". that might work, but that would mean, that for every path in the xml file (up to 2000 or more) i would have to compare to every path in my database (again, up to 2000 or maybe many more). i don't even want to calculate how many cpu calls this will generate... the hashtable lookup would just be way faster, if i could get the paths right.
    anyway, thanks for all the replies yet, you're really helpful. i'm aware of the filepath differences between windows and mac, and thanks again for your thorough explanations, but as i can't change the behaviour of this third party app i'm stuck with a solution here (and my mac os experience is near zero, but it is starting to get better ;=)

  • What path to use to access network files from Java app running on Mac

    I have a Java app running on a Mac with OS X that I'm using to check for files that exists on Windows servers within our network.
    Using a path like /Volumes/<Share>/ works because I've already connected to the drive using Finder. If I try to use a fully qualify the path with "smb://<Server>/<Share>" then my app doesn't see anything. Is there any way that I can get Java to connect to a directory without first having mapped or made the connection via some external tool like Finder?
    Here's the code I'm testing with:
    package FileImports;
    import java.io.File;
    import java.util.Arrays;
    public class Dir {
    static int indentLevel = -1;
    static void listPath(File path) {
    File files[];
    indentLevel++;
    files = path.listFiles();
    if (!(files == null)){
    Arrays.sort(files);
    for (int i = 0, n = files.length; i < n; i++) {
    for (int indent = 0; indent < indentLevel; indent++) {
    System.out.print(" ");
    System.out.println(files.toString());
    if (files[i].isDirectory()) {
    listPath(files[i]);
    indentLevel--;
    } else System.out.println("Directory not accessible!");
    public static void main(String args[]) {
    // this path works where <share> = the directory where my files exist.
    listPath(new File("/Volumes/<share>"));
    // this path returns a null result in files
    // listPath(new File("smb://<Server>/<Share>/"));
    Thanks,
    Alex
    Edited by: agates on Sep 25, 2008 11:14 AM

    agates wrote:
    Thanks for the response. I'll have to dig a little deeper into JCIFS. It looks like it would work great windows to windows. I haven't been able to find in the documentation where it would work on OS X without having to mount the targeted file system first. Has anyone had success creating a connection to a windows file system from OS X with JCIFS?Since jCIFS is written in pure Java and implements the entire SMB/CIFS protocoll on it's own it doesn't require any support from the OS (apart from a normal JVM runnig). Thus it should work exactly the same in OS X and Windows (and Linux and Solaris and ...).

  • Standard Midi File Import/Export Questions

    Hi,
    I'm having some trouble with Standard MIDI files, in that, after exporting them, and importing them back into another Logic project to test them, some of them will split/demix. That is, instead of one MIDI region appearing, it imports as two MIDI regions, with the notes of the part split between the two regions (the notes seem to split according to velocity, not note value).
    Here is my question related to this:
    Is it possible to export a Standard MIDI File for each "part" in a project, rather than one SMF for all the MIDI files in a project? (i.e., create one SMF for each software instrument track)? This is what I'm trying to do. The reason is that I'm trying to prepare and save some MIDI files to include with the audio files in a remix pack, and, since it's likely that the various remixers will be using different DAWs such as Cubase, I'm assuming that a SMF that includes all the various parts might not import into their program correctly. Is my assumption wrong? I.E., will most DAWs, like Cubase, etc., correctly import a SMF that includes all parts, and upon import split those parts correctly?
    I'm following all the instructions for "Saving Standard MIDI Files" from the Logic Pro manual, except that I am not merging all the different instruments' MIDI regions together; I'm only merging each individual parts' MIDI regions.
    Thanks!
    Message was edited by: trobert225 - I accidentally posted before I finished the question.

    Well I think the problem is solved. There was a conflict between Logic and iLife 06. I bought a new computer this week and had to load everything into it. I decided not to put in iLife 06 yet including Garageband and all the jam packs. I loaded all the new .caf files off the Logic DVD
    I opened a midi file and all tracks loaded with Logic instruments. the problem was that a lot of the instruments had been erased somehow or over written by Logic studio. Now I believe they are all there and things are working as they should

Maybe you are looking for

  • One time vendor invoice

    Hi Experts, I noticed that when I create invoice for one time vendor, the vendor data fields available is different with the normal vendor master data fields. Example : in normal vendor master data, there's field Street4. In the one time vendor maste

  • How to uninstall ss12u1 on solaris 10: lock file?

    hello all, the process of installation was interrupted, and ss12u1 is partially installed. I want to uninstall it but it's not possible: fury-root% ./uninstall.sh --non-interactive Configuring the installer... Searching for JVM on the system... Extra

  • NetInstall & NetRestore fail when attempting to connect/install.

    I'm trying to get a 10.6.4 server to host NetInstall & NetRestore images to build workstations on in classrooms. We've created a NetInstall from a base OS X 10.6 install DVD. Additionally, we've created a NetRestore image from a 'Golden Master' works

  • Restored database, can't perform 'System Restore'

    We've just performed a system reset of a system by performing a database restore to a version from a few months back.  I now need to reapply the SC's that have been modified since the initial database snapshot. However, when I try to perform a restor

  • Variable Speed

    I have a clip that is say 6 seconds long (excluding trailers), Let's say it is a guy that is running and jumps a creek and then runs again. I want to slow it down for the portion he is in the air during the jimp then speed it back up when he is runni