Exemplo n.º 1
0
 /**
  * setChanmute(int, boolean) takes a channel-number as an int and and a boolean to mute or unmute
  * that channel. Check the mute status of the channel first with getChanmute(channel).
  */
 public void setChanmute(int chan, boolean flip) {
   if (chan < player.get_num_channels()) {
     if (flip) {
       player.ibxm.chanmute[chan] = true;
     } else {
       player.ibxm.chanmute[chan] = false;
     }
   }
 }
Exemplo n.º 2
0
  public void sampleDump() {
    if (loadSuccess > 0) {
      try {
        for (int i = 0; i < (player.get_num_instruments() - 1); i++) {
          Sample sampshort = new Sample();
          sampshort = player.module.instruments[i].get_sample(i);
          byte[] samp = new byte[sampshort.sample_data.length];
          for (int j = 0; j < sampshort.sample_data.length; j++) {
            samp[j] = (byte) ((sampshort.sample_data[j] >> 8) & 0xff);
          }

          p.saveBytes(player.ins_name(i) + i + ".raw", samp);
          System.out.println("Sample " + i + " written to disk.");
        }
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
Exemplo n.º 3
0
  // This is f*****g stupid as hell; if this method makes it into a release, somebody shoot me in
  // the head.
  public void delayTap1(int channel, int volume) {

    try {
      InputStream file_input_stream = p.createInput(modpath);
      delayplayerA = new Player(interpolation);

      delayplayerA.set_module(Player.load_module(file_input_stream));
      file_input_stream.close();
      delayplayerA.set_loop(true);
      delayplayerA.receivebuffer(buffersize);

      for (int i = 0; i < delayplayerA.get_num_channels(); i++) {
        if (i != channel) {
          delayplayerA.ibxm.chanmute[i] = true;
        }
      }
      delayplayerA.ibxm.channels[channel].chanvol_override = volume;

      delayplayerA.play();
    } catch (IllegalArgumentException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (LineUnavailableException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
Exemplo n.º 4
0
 void displayCurrentpattern() {
   for (int thisrow = 0; thisrow < currentpatternrows[0].size(); thisrow++) {
     for (int channelcount = 0; channelcount < player.get_num_channels(); channelcount++) {
       try {
         CurrentPattern tempdata =
             (CurrentPattern)
                 currentpatternrows[channelcount].get(
                     thisrow); // channelcount works, thisrow is often out of bounds
       } catch (Exception e) {
         // TODO Auto-generated catch block
         e.printStackTrace();
       }
     }
   }
 }
Exemplo n.º 5
0
 /**
  * setStereosep(int) takes a percentage for desired MOD stereo spread. 100 gives full Amiga
  * hard-panning while 0 centres all channels. This only works on 4 or 8 channel files that are
  * verified as being MODs. Panning arrangement is 1:L 2:R 3:R 4:L(5:L 6:R 7:R 8:L). Just to be
  * clear, this has no effect on XM or S3M files!
  */
 public void setStereosep(int percentage) {
   int spread = (int) PApplet.map(percentage, 0, 100, 0, 128);
   if (modtype == "MOD") {
     player.ibxm.channels[0].set_panning(128 - spread);
     player.ibxm.channels[1].set_panning(128 + spread);
     player.ibxm.channels[2].set_panning(128 + spread);
     player.ibxm.channels[3].set_panning(128 - spread);
     if (player.get_num_channels() > 4) {
       player.ibxm.channels[4].set_panning(128 - spread);
       player.ibxm.channels[5].set_panning(128 + spread);
       player.ibxm.channels[6].set_panning(128 + spread);
       player.ibxm.channels[7].set_panning(128 - spread);
     }
   }
 }
Exemplo n.º 6
0
  /**
   * setTranspose(int, int) shifts playback key up or down by 12 semitones, while retaining tempo.
   * If chan is set to -1, all channels are transposed.
   */
  public void setTranspose(int chan, int trans) {
    if (chan < 0) {
      if (trans >= -12 && trans <= 12) {

        for (int i = 0; i < player.get_num_channels(); i++) {
          player.ibxm.channels[i].transposer = trans;
        }
        transpose = trans;
      }
    } else {
      if (trans >= -12 && trans <= 12) {
        player.ibxm.channels[chan].transposer = trans;

        chantranspose[chan] = trans;
      }
    }
  }
Exemplo n.º 7
0
  /**
   * Load the MOD/XM/S3M module by filepath string. If the second parameter is false, the module
   * will not automatically start to play. The third parameter is the starting volume as a float
   * value between -40.0f and 6.020f. Start at the bottom if you want to fade a module in.
   *
   * @return int
   */
  public int doModLoad(String tune, boolean autostart, int startVol) {
    filepath = tune;
    modpath = tune;
    headerCheck(tune);
    PApplet.println("Header checked: " + modtype);

    if (loadSuccess > 0) {
      loadSuccess = 0;
    }

    InputStream file_input_stream = p.createInput(tune);

    try {
      if (playing == true) {
        player.stop();
        PApplet.println("stopped");
      }
      player = new Player(interpolation);

      player.set_module(Player.load_module(file_input_stream));
      file_input_stream.close();
      player.set_loop(true);
      player.receivebuffer(buffersize);
      if (autostart) {
        player.play();
        songStart = p.millis();
      }
      this.setGlobvol(startVol);
      PApplet.println(player.get_title());
      PApplet.println(player.song_duration);

      songLength = player.song_duration / 48000;
      infotext = new String[player.get_num_instruments()];

      for (int i = 0; i < (player.get_num_instruments()); i++) {
        infotext[i] = "";
        // store copies of all the instruments for changeSample
        Instrument tempinst_old = player.module.instruments[i];
        oldsamples.add(i, tempinst_old);
        if (player.ins_name(i) != null) {
          PApplet.println(player.ins_name(i));
          infotext[i] = player.ins_name(i);
        }
      }

      chantranspose = new int[player.get_num_channels()];
      for (int c = 0; c < player.get_num_channels(); c++) {
        chantranspose[c] = 0;
      }
      loopstart = new int[player.get_num_instruments()];
      looplength = new int[player.get_num_instruments()];
      origloopstart = new int[player.get_num_instruments()];
      origlooplength = new int[player.get_num_instruments()];
      sampledatalength = new int[player.get_num_instruments()];
      for (int ins = 0; ins < player.get_num_instruments(); ins++) {
        // initialise loopinfo arrays
        origloopstart[ins] = 0;
        origlooplength[ins] = 0;
        sampledatalength[ins] = player.module.instruments[ins].samples[0].sample_data_length;
        // store initial loop info for loopReset
        // System.out.println("Orig start: " +
        // player.module.instruments[ins].samples[0].loop_start);
        // System.out.println("Orig length: "
        // +player.module.instruments[ins].samples[0].loop_length);
        origloopstart[ins] = player.module.instruments[ins].samples[0].loop_start;
        origlooplength[ins] = player.module.instruments[ins].samples[0].loop_length;
      }

      PApplet.println("Channels:" + player.get_num_channels());
      // PApplet.println(player.output_line.getControls());

      try {
        // volCtrl = (FloatControl) player.output_line.getControl(FloatControl.Type.MASTER_GAIN);
        // volCtrl.setValue(startVol);
      } catch (Exception e) {
        PApplet.println(
            "Mystery javasound failure lucky dip! This week's prize: " + e.getMessage());
      }

      try {
        muteCtrl = (BooleanControl) player.output_line.getControl(BooleanControl.Type.MUTE);
      } catch (Exception e) {
        PApplet.println(e.getMessage());
      }
      /*			for (int i=0; i < numchannels; i++){
      	globvol = startVol;
      	try {
      		player.ibxm.channels[i].chanvol_override = startVol;
      	} catch (Exception e) {
      		// TODO Auto-generated catch block
      		e.printStackTrace();
      	}
      }*/

      title = player.get_title();
      numchannels = player.get_num_channels();
      jamnote = new int[player.get_num_channels()];
      jaminst = new int[player.get_num_channels()];
      for (int c = 0; c < player.get_num_channels(); c++) {
        jamnote[c] = 0;
        jaminst[c] = 0;
      }
      numinstruments = player.get_num_instruments();
      numpatterns = player.ibxm.module.get_sequence_length();
      playing = true;
      loadSuccess = 1;
      initialtempo = player.get_bpm();
      bpmvalue = player.get_bpm();
      currentrowcount = player.ibxm.total_rows;
      endcount = 0;
      //		if (player.get_num_channels() > 0) {
      //			sequencecounter = 0;
      //			refreshpattern();
      //			displayCurrentpattern();
      //		}
    } catch (Exception e) {
      PApplet.println(e.getMessage());
      PApplet.println("Printing stack trace... ");
      e.printStackTrace();
    }
    return loadSuccess;
  }
Exemplo n.º 8
0
 /** setSeek(int) sets the current position of the song in milliseconds, from an int parameter. */
 public void setSeek(int newpos) {
   player.seek(newpos * 48);
 }
Exemplo n.º 9
0
 /** loopSong() switches song-looping on or off. mymod.looping shows the current status. */
 public void setSongloop(boolean flip) {
   player.loop = flip;
   System.out.println("Song looping is " + flip);
 }
Exemplo n.º 10
0
 /** setTempo(int) adjusts tempo in beats-per-minute when given an int value between 32 and 255 */
 public void setTempo(int tempo) {
   if (tempo > 32 && tempo < 255) {
     player.set_tempo(tempo);
     bpmvalue = tempo;
   }
 }
Exemplo n.º 11
0
 public void stop() {
   player.stop();
 }