Do Thing

Algorithmic music: A more recent rendition of the Technical Academy classic.

One response to “Do Thing

  1. Bobby Lee

    Source code:

    package com.b0b.academy;
    
    import jm.music.data.*;
    import jm.JMC;
    
    /**
     * Title: Dothing
     * Description: This is a port of the Technical Academy file "dothing",
     *                 written in Forth, dated 30Dec89
     * Copyright (c) 1989, 2002
     * @author b0b Lee
     */
    
    public class Dothing extends Rand implements JMC
    {
      public Dothing()
      {  }
    
      void wha(int its, Phrase phrase, int volume, int bottom)
      {
        phrase.add(new Note(bottom, WHOLE_NOTE, volume));
    
        for (int i = 3; i < (its + 3); ++i)
        {
          volume = volume + (get(21) - 10);
          // clamp the volume
          // volume = Math.max(volume, 24);
          // volume = Math.min(volume, 105);
    
          int third = i / 3;
          int pitch = bottom + ((get(37) / third) * third);
          pitch = Math.min(pitch, 127);
          phrase.add(new Note(pitch, QUARTER_NOTE, volume));
        }
    
        phrase.add(new Note(bottom, WHOLE_NOTE, volume));
      }
    
      Phrase do1 = new Phrase(0);
      Phrase do2 = new Phrase(0);
      Phrase do3 = new Phrase(SIXTEENTH_NOTE);
      Phrase do4 = new Phrase(SIXTEENTH_NOTE * 3.0);
      Phrase do5 = new Phrase(EIGHTH_NOTE);
      Phrase do6 = new Phrase(THIRTYSECOND_NOTE * 5.0);
    
      void thing(int its)
      {
        wha(its, do1, 35, 40);
        wha(its, do2, 80, 33);
        wha(its, do3, 60, 43);
        wha(its, do4, 30, 45);
        wha(its, do5, 70, 34);
        wha(its, do6, 60, 69);
        do6.add(new Note(0, THIRTYSECOND_NOTE, 0));
      }
    
      public Score getScore()
      {
        Score score = new Score();
        score.setTempo(144.0);
    
        thing(36);
        thing(72);
        thing(24);
        thing(96);
        thing(1);
    
        score.add(new Part(do1, "vibes", VIBRAPHONE, 0));
        score.add(new Part(do2, "bass", SLAP_BASS, 1));
        score.add(new Part(do3, "guitar1", SGUITAR, 2));
        score.add(new Part(do4, "guitar2", SGUITAR, 3));
        // don't set instrument on drum channels
        // synths know that channel 10 is for drums
        // note that setChannel is zero-based
        Part drum1 = new Part(do5, "drum1");
        drum1.setChannel(9);
        score.add(drum1);
        Part drum2 = new Part(do6, "drum2");
        drum2.setChannel(9);
        score.add(drum2);
    
        return score;
      }
    }
    

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

SoundHost.net

© 2010-2019 by bØb