View Single Post
  #1 (permalink)  
Old 10-08-2008, 12:14 AM
willemjav willemjav is offline
Senior Member
 
Join Date: Dec 2007
Location: Spain
Posts: 342
Rep Power: 3
willemjav is on a distinguished road
Default JAVA a cross-platform language? I have my doubts!
I have been working quit some time on a twenty-year-old Pascal program, translating it into java. The program manipulates a small Yamaha synthesizer called FBO-1. Al the program does is sending timed midi code numbers to the synthesizer and there is where the problem lays. The midi code transition is based on large timed-loops (a swing clock of 7 mili sec is set). The problem I am experiencing is that the timing of each soundtrack is very different on PC compared to MAC (interesting to know is that my 8-year-sold-slow G4 mac synchronizes perfect with my new macbook, so it is definitely not a CPU speed problem). Curiously my MAC is much faster compared to the PC. Is there anybody who can shine some light on my JAVA-darkness, because for the moment the thing simply does not go on PC and I do not know what to do!
(I include the first sound track code as an example, the other tracks work on the same principle)





Code:
//--------------------------------------------------------------------
//klankblokken 1-----12


public void Soundblock1()  {
    
    int tel=0, teller=0, fractie=0, toon=0, tijd1=0, tijd2=0, 
            tijd3=0, i1=0, i2=0, i3=0, i4=0, i5=0, stem=0, 
            vel=0, waarde=0, x=0, y=0, toon1=0, toon2=0;
            cont.setpedFlag(false);
        System.out.println("entering in soundblock 1 " + (System.currentTimeMillis() - starttime));    
        cont.ed.midi_datadump(1,1,5);
        System.out.println("DATADUMP 1 DONE " + (System.currentTimeMillis() - starttime));
        cont.setInfo("      DATADUMP 1 DONE \n\n",false);
        cont.ed.midi_datadump(2,6,8);
        System.out.println("DATADUMP 2 DONE " + (System.currentTimeMillis() - starttime));
        cont.setInfo("      DATADUMP 2 DONE \n\n",true);
         
        cont.ed.midi_data(algemeen,"fdb",7,6,8);
        cont.ed.midi_stereo(1,1,links);
        cont.ed.midi_stereo(2,3,midde);
        cont.ed.midi_stereo(4,4,rechts);
        cont.ed.midi_stereo(5,6,links);
        cont.ed.midi_stereo(7,8,midde);
        cont.ed.midi_vel(1,4,67);
        cont.ed.midi_vel(5,8,97);
        
    System.out.println("WAITING FOR PEDAL 1 (time reset on start seq)  " + (System.currentTimeMillis() - starttime));
    cont.setInfo("      WAITING FOR PEDAL 1 \n\n",true);

    waitforPedal();
    System.out.println(" 1 pedal done ");
    cont.setInfo("      PEDAL 1 DONE \n\n",true);
    cont.clkset(6,237);
    
    do {
        if (cont.getescFlag())  {
        exit=true;              //exit the soundblock
        }
       
       if (cont.clkpls>=tel*7 && tel<=60) {
       
         tel=tel+1;
         cont.ed.midi_vel(1,4,67+tel);
       }
     
       if (cont.clkpls>=50*teller) { 
         teller=teller+1;
         
         if (teller>10 && teller<=40) cont.ed.midi_vel(5,8,97+teller-10);
       }

       if (teller==8)  cont.ed.midi_data(algemeen,"fdb",1,1,2);
       if (teller==12) cont.ed.midi_data(algemeen,"fdb",1,3,4);
       if (teller==14) cont.ed.midi_data(algemeen,"fdb",2,1,2);
       if (teller==19) cont.ed.midi_data(operator4,"lev",8,1,2);
       if (teller==23) cont.ed.midi_data(operator4,"lev",8,3,4);
       if (teller==25) cont.ed.midi_data(algemeen,"fdb",3,3,4);
       if (teller==29) cont.ed.midi_data(algemeen,"fdb",3,1,2);
       if (teller==31) cont.ed.midi_data(algemeen,"fdb",4,1,2);
       if (teller==34) cont.ed.midi_data(algemeen,"fdb",5,3,4);
       if (teller==38) cont.ed.midi_data(algemeen,"fdb",5,1,2);
       if (teller==40) cont.ed.midi_data(operator4,"lev",7,1,2);
       if (teller==43) cont.ed.midi_data(operator4,"lev",7,3,4);
       if (teller==45) cont.ed.midi_data(operator4,"lev",6,1,2);
       if (teller==49) cont.ed.midi_data(operator4,"lev",6,3,4);
       if (teller==52) cont.ed.midi_data(operator4,"lev",5,1,4);
       if (teller==53) cont.ed.midi_data(operator4,"lev",4,1,4);
       if (teller==55) cont.ed.midi_data(operator4,"lev",3,1,4);
       if (teller==56) cont.ed.midi_data(operator4,"lev",1,1,4);
       if (teller==57)  { 
         cont.ed.midi_data(operator4,"lev",0,1,4);
         cont.ed.midi_data(operator4,"d1r",6,1,4);
         cont.ed.midi_data(operator3,"lev",3,1,4);
         cont.ed.midi_data(algemeen,"fdb",7,1,4);
       }
       
     
       if (teller==12)  waarde=134;
       if (teller==19)  waarde=259;
       if (teller==23)  waarde=378;
       if (teller==30)  waarde=491;
       if (teller==37)  waarde=598;
       if (teller==43)  waarde=700;
       if (teller==52)  waarde=798;

       if (teller==6)  cont.ed.midi_vel(5,8,97);

       if (cont.clkpls>=tijd1) {
         tijd1=cont.ed.random(startgetal,80-teller,400-(6*teller))+tijd1; //?
        //System.out.println("tijd1 " + tijd1);
         if (teller<=58) { 
           boo1=false; boo2=false; boo3=false; boo4=false;
         }
         x = cont.ed.random(startgetal,1,4);
         y = cont.ed.random(startgetal,1,2);
        // System.out.println("boo1-4 " + x);
           if (x==1) boo1=true;
           else
           if (x==2) boo2=true;
           
           if (y==1) boo3=true;
           else
           if (y==2) boo4=true; 
       
       }    
       

       if (cont.clkpls>=7*i1)  {  //3
         i1=i1+1;
       
         if (boo1 || boo2)  {
           toon=cont.ed.random(startgetal,1,waarde);
           fractie= toon % 127;        
           toon= toon / 127;
           vel=cont.ed.random(startgetal,80,100);
           stem=cont.ed.random(startgetal,1,2);
           if (boo1=true)  stem=2;
           if (boo2=true)  stem=1;
           cont.ed.midi_toon(stem,50+toon,fractie,vel);
         }
       }
   
       if (cont.clkpls>=9*i2)  {  //4
         i2=i2+1;
         if (boo3 || boo4)  {
           toon=cont.ed.random(startgetal,1,waarde);
           fractie= toon % 127;
           toon= toon / 127;
           vel=cont.ed.random(startgetal,80,100);
           stem=cont.ed.random(startgetal,3,4);
           if (boo3=true)  stem=4;
           if (boo4=true)  stem=3;
           cont.ed.midi_toon(stem,50+toon,fractie,vel);
         }
       }

       if (cont.clkpls>=tijd3)  {
             
          cont.ed.midi_toon(5,20,cont.ed.random(startgetal,0,127),cont.ed.random(startgetal,50,80));
          tijd3 = cont.ed.random(startgetal,10,60)+tijd3;
       }
       
     
       if ((cont.clkpls>=400+tijd2) || (teller==56) || (teller==58))  {
          
         tijd2=cont.ed.random(startgetal,30,600)+tijd2;
         cont.ed.midi_data(algemeen,"fdb",cont.ed.random(startgetal,5,7),5,8);
         if (teller>=58)  { 
           cont.ed.midi_data(algemeen,"fdb",7,5,8);
           cont.ed.midi_data(operator4,"lev",0,5,8);
         }
         toon=cont.ed.random(startgetal,16,17);
        // System.out.println("ransdom 16-7 " + toon);
         fractie=cont.ed.random(startgetal,0,127);
         cont.ed.midi_toon(5,toon,fractie,127);
      
         toon=cont.ed.random(startgetal,17,18);
         fractie=cont.ed.random(startgetal,0,127);
         cont.ed.midi_toon(6,toon,fractie,127);

         toon=cont.ed.random(startgetal,18,19);
         fractie=cont.ed.random(startgetal,0,127);
         cont.ed.midi_toon(7,toon,fractie,127);
       }
    } while (teller<61 && !exit);
     
  //midi datadump no 3
   
        cont.ed.midi_datadump(1,6,7);
        System.out.println("DATADUMP 3 DONE");
        cont.setInfo("      DATADUMP 3 DONE \n\n",false);
       

        cont.ed.midi_data(algemeen,"fdb",6,1,8); 
        cont.ed.midi_data(operator4,"d1r",3,1,8);
        cont.ed.midi_data(operator4,"lev",4,1,8);
        cont.ed.midi_data(operator3,"lev",7,1,8);
      
       cont.clkset(6,237);
       cont.ed.midi_toon(1,50+b_toon1,b_fractie1,127);
       do {} while (cont.clkpls<=3);
       cont.ed.midi_toon(2,50+b_toon2,b_fractie2,127);
       cont.ed.midi_toon(3,50+b_toon3,b_fractie3,127);
       do {} while (cont.clkpls<=7);
       cont.ed.midi_toon(4,50+b_toon4,b_fractie4,127);
       do {} while (cont.clkpls<=5);
       cont.ed.midi_toon(5,50+b_toon5,b_fractie5,127);
       do {} while (cont.clkpls<=4);
       cont.ed.midi_toon(6,50+b_toon6,b_fractie6,127);
       cont.ed.midi_toon(7,50+b_toon7,b_fractie7,127);
   
       do {
          
      
       } while (cont.clkpls<700 && !exit );

       cont.ed.midi_toon(3,50+b_toon3,b_fractie3,0);
       cont.ed.midi_toon(4,50+b_toon4,b_fractie4,0);
  }
Reply With Quote