Noise and Academia

Talk about noise music. Reviews, rants, whatever.

Moderator: xome

User avatar
DonaldKrump
Posts: 241
Joined: Mon Oct 10, 2016 8:27 pm
Contact:

Re: Noise and Academia

Post by DonaldKrump » Mon Jul 02, 2018 3:01 pm

jliat wrote:
Sun Jul 01, 2018 11:32 pm
DonaldKrump wrote:
Sun Jul 01, 2018 10:05 am
between videos and Pollack and side comments, this thread is roller coaster and my heads still spinning. Can't keep up with your dialogue, haha. So many subtopics...



= NOISE
Ha! Thanks, I really needed that reminder. Perspective realignment = check.

User avatar
melkobukva
Posts: 320
Joined: Thu Jan 04, 2018 6:35 pm

Re: Noise and Academia

Post by melkobukva » Mon Jul 02, 2018 3:58 pm

DonaldKrump wrote:
Mon Jul 02, 2018 3:01 pm
jliat wrote:
Sun Jul 01, 2018 11:32 pm
DonaldKrump wrote:
Sun Jul 01, 2018 10:05 am
between videos and Pollack and side comments, this thread is roller coaster and my heads still spinning. Can't keep up with your dialogue, haha. So many subtopics...



= NOISE
Ha! Thanks, I really needed that reminder. Perspective realignment = check.
A relevant quote from another thread:
jliat wrote:
Tue May 01, 2018 6:49 am
crochambeau wrote:
Tue May 01, 2018 6:40 am


Honestly, eliminating a fixed tempo and just dealing with raw sound for a bit can do wonders for your perception of the more structured works.
Which reminds me - my first encounter with Stockhausen's work, after immersing myself for a few days i walked past the metalwork shop at college and heard "music"!!!

User avatar
jliat
Posts: 2690
Joined: Tue Nov 20, 2012 1:34 am
Contact:

Re: Noise and Academia

Post by jliat » Tue Jul 03, 2018 1:42 am

WhiteWarlock wrote:
Mon Jul 02, 2018 8:58 am
//IMPROVED NOISE

http://www.jliat.com/download/HNW90.zip

Listing-

1 //MAKES HNW EACH RUN USES RANDOM KEY -
2 import javax.sound.sampled.*;
3 import java.util.*;
4 public class HNW90{
5 //The following are general instance variables
6 // used to create a SourceDataLine object.
7 AudioFormat audioFormat;
8 AudioInputStream audioInputStream;
9 SourceDataLine sourceDataLine;
10 //The following are audio format parameters.
11 float sampleRate = 16000.0F;
12 //Allowable 8000,11025,16000,22050,44100
13 int sampleSizeInBits = 16;
14 //Allowable 8,16
15 int channels = 1;
16 // MONO!
17 //Allowable 1,2
18 boolean signed = true;
19 //Allowable true,false
20 boolean bigEndian = true;
21 //Allowable true,false
22 //
23 // size of number of samples to smooth
24 // larger = more coarse sounds
25 static int harshness = 200;
26 static int noiselen = 0; // length of piece 0 = infinite!
27 //-------------------------------------------//
28 public static void main(String args[]){
29 Random generator = new Random();
30 harshness = generator.nextInt(200);
31 new HNW90();
32 }//end main
33 //-------------------------------------------//
34 public HNW90(){//constructor
35 playData();
36 }//end constructor
37
38 private void playData() {
39 try{
40 //Get the required audio format
41 audioFormat = new AudioFormat(
42 sampleRate,
43 sampleSizeInBits,
44 channels,
45 signed,
46 bigEndian);
47 //Get info on the required data line
48 DataLine.Info dataLineInfo =
49 new DataLine.Info(
50 SourceDataLine.class,
51 audioFormat);
52 //Get a SourceDataLine object
53 sourceDataLine = (SourceDataLine)AudioSystem.getLine(dataLineInfo);
54 new ListenThread().start();
55 }catch (Exception e) {
56 e.printStackTrace();
57 System.exit(0);
58 }//end catch
59 }//end playData
60 //=============================================//
61 class ListenThread extends Thread{
62 byte playBuffer[] = new byte[200];
63 // the size of this buffer = length of sound
64 public void run(){
65 // need to generate random numbers
66 Random generator = new Random();
67 // harshness the higher this value the more rough/harsh
68 double ss[] = new double[harshness];
69 double sa;
70 short s; // signed two byte integer for PCM data
71 try{
72 sourceDataLine.open(audioFormat);
73 sourceDataLine.start();
74 for(int z = -1; z < noiselen; z++){
// make this big for long pieces or
75 // if noiselen was 0 from commandline run forever!
76 // note only play half buffer to stop gaps???
77 if (noiselen < 1) z = -2;
78 //----------------------- loop ------------------------
79 for(int cnt = 0; cnt < 100; cnt = cnt + 2 ){
80 // for testing so i can see the data
81 // for(int cnt = 0; cnt < 100; cnt = cnt + 2 ){
82 int r = generator.nextInt();
83 s = (short) r;
84 // store new sample - roll out others
85 For(int x = 0; x < harshness-1; x++){
86 ss[x] = ss[x+1];
87 } // end of x for
88 ss[harshness-1] = (short)s;
89 // average the last harshness number of samples
90 // remove the higher pitches
91 sa = 0;
92 for(int x = 0; x < harshness; x++){
93 sa = sa + ss[x];
94 }
95 sa = sa / harshness;
96 s = (short) sa;
97 //============ Process for new sounds ========
98 // loudness==== !!!!
99 // basically no wimpy numbers - only fat ones
100 if (s > 0 & s < 30000) {s = (short) (s + 30000);}
101 if (s < 0 & s > -30000) {s = (short) (s - 30000);}
102
103 // System.out.println(s);
104 //=============== End of Process ============
105 //asheutput stream is a byte array load the low/high integer
106 byte hexBase ;
107 // A byte of all ones
108 hexBase = (byte) 255;
109 byte b1 = (byte) (hexBase & s);
110 byte b2 = (byte) ((hexBase <<(8)& s) >> 8);
111 //System.out.println(b1);
112 playBuffer[cnt] = b2 ;
113 playBuffer[cnt+1] = b1 ;
114 }
115 sourceDataLine.write(playBuffer, 0, 100);
116 } // end of loop
117 // -------------------------- loop ---------------------
118 //Block and wait for internal buffer of the
119 // SourceDataLine to become empty.
120 sourceDataLine.drain();
121 //Finish with the SourceDataLine
122 sourceDataLine.stop();
123 sourceDataLine.close();
124
125 }catch (Exception e) {
126 e.printStackTrace();
127 System.exit(0);
128 }//end catch
129 }//end run
130 }//end inner class ListenThread
131 }//end outer class

User avatar
WhiteWarlock
Posts: 1763
Joined: Tue Apr 10, 2018 7:58 am

Re: Noise and Academia

Post by WhiteWarlock » Tue Jul 03, 2018 8:25 am

Thanks that's what was hinting...
figured you had some "noise source" for throwing as response
//plus it's better reading for me :P
// basically no wimpy numbers - only fat ones
into the (void)
heads will start spinning like Linda Blair's in the Exorcist
Image

Code: Select all

#include "ext.h"
#include "z_dsp.h"
#include <cstdlib>      /* included for rand() function */
#include <ctime>        /* included for time() function */

typedef struct {
   t_pxobject msp_data; 
} MyObject;

void*  object_data;     

void   main             (void);
void*  create_object    (void);
void   InputSeed        (MyObject* mo, long value);
void   MessageDSP       (MyObject* mo, t_signal** signal, short* count);
t_int* Perform          (t_int *parameters);
float  randfloat        (void);

void main(void) {
   setup((t_messlist**)&object_data, (method)create_object, 
         (method)dsp_free, (short)sizeof(MyObject), NULL, A_NOTHING);
   addint((method)InputSeed);    
   addmess((method)MessageDSP, "dsp", A_CANT, A_NOTHING);
   dsp_initclass();
}

void* create_object(void) {
   MyObject *mo = (MyObject*)newobject(object_data);
   dsp_setup((t_pxobject*)mo, 0);           
   outlet_new((t_pxobject*)mo, "signal");   
   InputSeed(mo, time(NULL));               
   return mo;
}

void InputSeed(MyObject *mo, long value) {
   #pragma unused(mo)
   srand(value);
}

void MessageDSP(MyObject* mo, t_signal** signal, short* count) {
   #pragma unused(mo)
   #pragma unused(count)
   dsp_add(Perform, 3, 3, signal[0]->s_vec, signal[0]->s_n);
}

t_int* Perform(t_int *parameters) {
   long      pcount = (long)     (parameters[1]);
   t_float  *output = (t_float*) (parameters[2]);
   long      count  = (int)      (parameters[3]);
   long      i;

   for (i=0; i<count; i++) {
      output[i] = randfloat() * 2.0 - 1.0;
   }

   return parameters+pcount+1;   
}

float randfloat(void) {
   return (float)rand()/RAND_MAX;
}
float trianglerand(void) {
   return floatrand() + floatrand() / 2.0;
}
float trianglerand(float lower, float upper, float max) {
   float norm = floatrand()+floatrand();
   float output;

   // scale each side of the triangle to the requested range:
   if (norm < 1.0) {
      output = (norm - 1.0) * lower + max;
   } else {
      output = (norm - 1.0) * upper + max;
   }
  
   // normalize the sides of the triangle so that the probability
   // densities matchup at the maximum:
   if (lower == upper) {
      return output;
   } else if (output < max && lower < upper) {
      if (floatrand() < (float)lower/upper) {
         return output;
      } else {
         return trianglerand();
      }
   } else if (output > max && upper < lower) {
      if (floatrand() < (float)upper/lower) {
         return output;
      } else {
         return trianglerand();
      }
   }

   return output;
}
Last edited by WhiteWarlock on Thu Jul 05, 2018 8:37 am, edited 1 time in total.

User avatar
WhiteWarlock
Posts: 1763
Joined: Tue Apr 10, 2018 7:58 am

Re: Noise and Academia

Post by WhiteWarlock » Tue Jul 03, 2018 10:52 am

How about starting "Thread Archive" for DSP/MIDI Source Code?

User avatar
WhiteWarlock
Posts: 1763
Joined: Tue Apr 10, 2018 7:58 am

Re: Noise and Academia

Post by WhiteWarlock » Tue Jul 03, 2018 8:39 pm

Putnam, L. (2014). Gamma: A C++ sound synthesis library further abstracting the unit generator. In Proceedings of the 2014 International Computer Music Conference, pages 1382–1387, Athens, Greece.
http://hdl.handle.net/2027/spo.bbp2372.2014.211
http://w2.mat.ucsb.edu/gamma/
Does anyone have PDF copy of an "old" book by Embree:
C++ Algorithms for Digital Signal Processing
C Algorithms for Real-time DSP
or have any good books/papers suggestions on the subject of "DSP" & "Academia"
C/C++
Henon Map
M. Hénon (1976). "A two-dimensional mapping with a strange attractor". Communications in Mathematical Physics.
https://en.wikipedia.org/wiki/H%C3%A9non_map

User avatar
WhiteWarlock
Posts: 1763
Joined: Tue Apr 10, 2018 7:58 am

Re: Noise and Academia

Post by WhiteWarlock » Tue Jul 03, 2018 10:59 pm

HENON'S EQUATION
Image

xn+1= 1 - axn2 + bxn,
(a and b are parameters)

Michel Henon, an astronomer at the observatory in Nice, France, was born in Paris in 1931. Curious about the degradation of celestial orbits, he began to model the orbits of stars around the centers of their galaxies.
Henon considered gravitational centers as a three dimensional object (as opposed to a point in space) and carefully studied the orbits of the stars. To simplify the task of trying to track a three dimensional orbit, he considered, instead, the intersection of a plane with these orbits. Initially, the intersection points appeared to be completely random in their location, moving from one edge of the plane to the next. However, after a few dozen points were plotted, a closed, egg-shaped curve began to appear. This mapping was, apparently, the cross section of a torus (i.e., a doughnut).
Henon (along with one of his graduate students) continued to study this mapping and continued plotting the points for a system with increased energy levels. Once the newer mappings were made, though, the continuous curve began fading and random points began to appear proportionally to the energy. Over the years, Henon tried many ways to predict the upcoming points of his high-energy graph until finally, he decided to abandon classical methods and use difference equations.
Applying a formula to force the data into the shape of a crescent moon, Henon found some interesting results. The formula was fairly simple. Take the old y and multiply it by 0.3 (b). Then subtract 1.4 (a) times the old x squared. Finally add one to the whole equation. This yields this system:
Image
xnew= y - 1.4x2 + 1
ynew= 0.3x


Although, at first, it seems like an ordinary curve, closer inspection reveals distinct curves, one thicker than the other. If we magnify the picture, we see that each of these curves is also made up of two similar curves. This happens for every possible magnification of the curve.
Image

In astronomy, Michel Hénon was a leading figure in the field of stellar dynamics, galactic dynamics, and the evolution of the rings of Saturn. In mathematics, he is known for the so-called Hénon maps and attractor, which is one of the most studied chaotic systems.
In the late 1960s and early 70s, he worked on the star clusters and by using Monte Carlo methods, he developed numerical techniques to follow the dynamics of globular clusters. His probabilistic method proved to be much faster than usual N-body methods.
He published a two volume book on restricted three-body problem.

He died on April 2013 in Nice.
http://adsabs.harvard.edu/cgi-bin/nph-a ... &version=1
https://arxiv.org/pdf/1411.4930
https://www.youtube.com/playlist?list=P ... 6-akNgLG7-_

C++ Henon Source Code

Code: Select all

//
// Programmer:    Craig Stuart Sapp <craig@ccrma.stanford.edu>
// Creation Date: Wed Jan  9 14:29:54 PST 2002
// Last Modified: Thu Jan 10 23:19:05 PST 2002
// Last Modified: Thu Apr  3 10:23:41 PST 2008 (added Humdrum output)
// Filename:      ...sig/examples/all/henonfile.cpp
// Web Address:   http://sig.sapp.org/examples/improv/improv/henonfile.cpp
// Syntax:        C++; museinfo
//
// Description:   Creates a fractal melodic line based on the
//                Henon Map.  Output can be either a MIDI file or
//                plain text.
//

#include "MidiFile.h"
#include "Convert.h"
#include "Options.h"
#include "CircularBuffer.h"
#include <string.h>
#include <stdio.h>

using namespace std;


// function declarations:
void        checkOptions        (Options& opts, int argc, char** argv);
void        example             (void);
void        usage               (const char* command);
void        createHenon         (double alpha, double beta, double x0,
                                 double y0, int maxcount, MidiFile& midifile);
int         checkTermination    (int key);
void        storeInMidiFile     (MidiFile& midifile, int key);
void        printGuidoNotation  (void);
void        printHumdrumNotation(void);
char*       convertMidiToGuido  (char* buffer, Array<char> notelist, int index);
void        printLeftHand       (void);
void        printRightHand      (void);

// User interface variables:
Options     options;
int         maxcount  = 10000;  // used with the -n option
double      alpha = -1.56693;   // used with the -a option
double      beta  = -0.011811;  // used with the -b option
double      x0 = 0.0;           // x-axis starting point
double      y0e = 0.0;          // y-axis starting point
int         textQ = 0;          // used with the --text option
int         guidoQ = 0;         // used with the -g option
int         humdrumQ = 0;       // used with the -u option
int         repeatQ = 0;        // used with the -r option
string      filename = "test.mid"; // filename to write MIDI file
int         tpq = 96;           // ticks per quarter note in MIDI file
int         divisions = 4;      // number of notes per quarter note
int         instrument = 0;     // used with the -i option
double      tempo = 120.0;      // used with the -t option
Array<char> notelist;           // for printing in Guido Music Notation
int         minNote = 30;       // minimum note to play
int         maxNote = 100;      // maximum note to play

//////////////////////////////////////////////////////////////////////////

int main(int argc, char** argv) {
   checkOptions(options, argc, argv); // process the command-line options

   MidiFile midifile;
   midifile.setTicksPerQuarterNote(tpq);
   midifile.allocateEvents(0, 2 * maxcount + 500);  // pre allocate space for
                                                    // max expected MIDI events
   notelist.setSize(maxcount+10);
   notelist.setSize(0);
   notelist.allowGrowth();

   midifile.absoluteTicks();

   vector<uchar> mididata(2);
   mididata[0] = 0xc0;       // patch change on MIDI channel 1
   mididata[1] = (uchar) instrument;  // user input instrument
   midifile.addEvent(0, 0, mididata);

   // write the tempo to the midifile
   mididata.resize(6);
   mididata[0] = 0xff;      // meta message
   mididata[1] = 0x51;      // tempo change
   mididata[2] = 0x03;      // three bytes to follow
   int microseconds = (int)(60.0 / tempo * 1000000.0 + 0.5);
   mididata[3] = (microseconds >> 16) & 0xff;
   mididata[4] = (microseconds >> 8)  & 0xff;
   mididata[5] = (microseconds >> 0)  & 0xff;
   midifile.addEvent(0, 0, mididata);

   createHenon(alpha, beta, x0, y0e, maxcount, midifile);
   if (guidoQ) {
      printGuidoNotation();
   } else if (humdrumQ) {
      printHumdrumNotation();
   } else {
      midifile.write(filename.c_str());
   }

   return 0;
}

//////////////////////////////////////////////////////////////////////////



//////////////////////////////
//
// createHenon --
//

void createHenon(double alpha, double beta, double x0, double y0e,
   int maxcount, MidiFile& midifile) {

   double x = x0;
   double y = y0e;
   double newx;
   double newy;
   int key;
   int termination = 0;
   int i;

   for (i=0; i<maxcount; i++) {
      newx = 1 + alpha * x * x + beta * y;
      newy = x;
      x = newx;
      y = newy;

      key = (int)((x + 1.0)/2.0 * 127.0 + 0.5);
      if (key < minNote) {
         key = 0;
      }
      if (key > maxNote) {
         key = 0;
      }
      if (repeatQ) {
         termination = 0;
      } else {
         termination = checkTermination(key);
      }
      if (textQ) {
         cout << key << "\n";
         if (termination != 0) {
            cout << "REPEAT" << termination << endl;
            exit(0);
         }
      } else {
         storeInMidiFile(midifile, key);
         if (termination != 0) {
            midifile.write(filename);
            exit(0);
         }
      }
   }

}



//////////////////////////////
//
// storeInMidiFile --
//

void storeInMidiFile(MidiFile& midifile, int key) {
   static int timer = tpq;   // start after one beat (for patch change)
   char note = (char)key;

   // don't store extreme notes -- this gives interesting rhythms sometimes.
   if (key < minNote || key > maxNote) {
      note = 0;
      notelist.append(note);
      timer += tpq/divisions;
      return;
   }
   notelist.append(note);       // store note for displaying Guido Notation
   vector<uchar> midinote(3);
   midinote[0] = 0x90;
   midinote[1] = key;
   midinote[2] = 64;
   midifile.addEvent(0, timer, midinote);
   midinote[0] = 0x80;
   timer += tpq/divisions;
   midifile.addEvent(0, timer, midinote);
}



//////////////////////////////
//
// checkTermination --
//

int checkTermination(int key) {
   static CircularBuffer<int> memory;
   static int init = 0;
   if (init == 0) {
      init = 1;
      memory.setSize(1000);
      memory.reset();
   }
   memory.insert(key);
   if (memory.getCount() < 40 + 10) {
      return 0;
   }

   int j;
   int i;
   int cycleQ;
   for (j=1; j<20; j++) {
      cycleQ = 1;
      for (i=0; i<40; i++) {
         if (memory[i] != memory[i+j]) {
            cycleQ = 0;
            break;
         }
      }
      if (cycleQ == 1) {
         return j;
      }
   }

   // no 1-9 period cycles detected
   return 0;

}




//////////////////////////////
//
// checkOptions --
//

void checkOptions(Options& opts, int argc, char* argv[]) {
   opts.define("n|max-number=i:10000", "Maximum number of notes to generate");
   opts.define("a|alpha=d:-1.56693",   "alpha factor");
   opts.define("b|beta=d:-0.011811",   "beta factor");
   opts.define("x|x0=d:0.0",           "initial x value");
   opts.define("y|y0=d:0.0",           "initial y value");
   opts.define("max|max-note=i:100",   "maximum note to play; higher is rest");
   opts.define("min|min-note=i:30",    "minimum note to play; lower is rest");
   opts.define("text=b",               "display output as text only");
   opts.define("g|guido=b",            "Guido Music Notation output");
   opts.define("u|humdrum=b",          "Humdrum data file output");
   opts.define("i|instrument=i:0",     "General MIDI instrument number");
   opts.define("t|tempo=d:120",        "Tempo");
   opts.define("d|divisions=i:4",      "Number of notes per quarter note");
   opts.define("r|allow-repeats=b",    "Do not stop at cyclical patterns");

   opts.define("author=b",  "author of program");
   opts.define("version=b", "compilation info");
   opts.define("example=b", "example usages");
   opts.define("h|help=b",  "short description");
   opts.process(argc, argv);

   // handle basic options:
   if (opts.getBoolean("author")) {
      cout << "Written by Craig Stuart Sapp, "
           << "craig@ccrma.stanford.edu, Jan 2002" << endl;
      exit(0);
   } else if (opts.getBoolean("version")) {
      cout << argv[0] << ", version: 3 Apr 2008" << endl;
      cout << "compiled: " << __DATE__ << endl;
      exit(0);
   } else if (opts.getBoolean("help")) {
      usage(opts.getCommand().c_str());
      exit(0);
   } else if (opts.getBoolean("example")) {
      example();
      exit(0);
   }

   maxcount   = opts.getInteger("max-number");
   alpha      = opts.getDouble("alpha");
   beta       = opts.getDouble("beta");
   x0         = opts.getDouble("x0");
   y0e        = opts.getDouble("y0");
   textQ      = opts.getBoolean("text");
   guidoQ     = opts.getBoolean("guido");
   humdrumQ   = opts.getBoolean("humdrum");
   if (textQ == 1) {
      guidoQ   = 0;
      humdrumQ = 0;
   }
   repeatQ    = opts.getBoolean("allow-repeats");
   tempo      = opts.getDouble("tempo");
   divisions  = opts.getInteger("divisions");
   instrument = opts.getInteger("instrument");

   maxNote = opts.getInteger("max-note");
   minNote = opts.getInteger("min-note");
   if (minNote < 0)   minNote = 0;
   if (minNote > 126) minNote = 126;
   if (maxNote < 0)   maxNote = 0;
   if (maxNote > 126) maxNote = 126;
   if (minNote > maxNote) {
      int temp = minNote;
      minNote = maxNote;
      maxNote = temp;
   }

   if (instrument < 0) {
      instrument = 0;
   } else if (instrument > 127) {
      instrument = 127;
   }

   if (tempo < 4) {
      tempo = 4;
   } else if (tempo > 1000) {
      tempo = 1000;
   }

   if (humdrumQ == 0 && guidoQ == 0 && textQ == 0 && opts.getArgCount() != 1) {
      usage(opts.getCommand().c_str());
      exit(1);
   }
   if (humdrumQ == 0 && textQ == 0 && guidoQ == 0) {
      filename = opts.getArg(1);
   }

}



//////////////////////////////
//
// example --
//

void example(void) {


}



//////////////////////////////
//
// usage --
//

void usage(const char* command) {
   cout << "Usage: " << command << " outputfile" << endl;

}



//////////////////////////////
//
// printGuidoNotation --
//

void printGuidoNotation(void) {
   cout << "{ ";
   printRightHand();
   cout << ", ";
   printLeftHand();
   cout << " }\n";
}



//////////////////////////////
//
// printHumdrumNotation --
//

void printHumdrumNotation(void) {
   char buffer[1024] = {0};
   cout << "!!!alpha:\t" << alpha << "\n";
   cout << "!!!beta:\t" << beta << "\n";
   cout << "!!!start:\t(" << x0 << ", " << y0e << ")\n";
   cout << "**kern\n";
   int i;
   for (i=0; i<notelist.getSize(); i++) {
      cout << "16";
      if (notelist[i] <= 0) {
         cout << "r";
      } else {
         cout << Convert::base12ToKern(buffer, notelist[i]);
      }
      cout << "\n";
      if ((i+1) % 32 == 0) {
         cout << "=" << (i / 32) + 2 << "\n";
      }

   }
   cout << "*-" << endl;
}



//////////////////////////////
//
// printRightHand --
//

void printRightHand(void) {
   char buffer[128] = {0};
   cout << "[";
   int i;
   cout << "\\meter<\"2/4\">\n";
   for (i=0; i<notelist.getSize(); i++) {
      if (notelist[i] >= 60) {
         cout << convertMidiToGuido(buffer, notelist, i) << " ";
      } else {
         cout << "_/16" << " ";
      }
      if ((i+1)%16 == 0) {
         cout << "\n\t";
      }
   }
   cout << "]\n";
}



//////////////////////////////
//
// printLeftHand --
//

void printLeftHand(void) {
   char buffer[128] = {0};
   cout << "[";
   int i;
   cout << "\\meter<\"2/4\">\n";
   for (i=0; i<notelist.getSize(); i++) {
      if (notelist[i] < 60) {
         cout << convertMidiToGuido(buffer, notelist, i) << " ";
      } else {
         cout << "_/16" << " ";
      }
      if ((i+1)%16 == 0) {
         cout << "\n\t";
      }
   }
   cout << "]\n";
}



//////////////////////////////
//
// convertMidiToGuido -- convert from MIDI note number to Guido Music
//     Notation note name.
//

char* convertMidiToGuido(char* buffer, Array<char> notelist, int index) {
   if (notelist[index] == 0) {
      strcpy(buffer, "_/16");
      return buffer;
   }
   int octave = (int)notelist[index] / 12 - 4;
   if (octave > 2) octave--;

   char octbuf[32] = {0};
   sprintf(octbuf, "%d", octave);

   int pc = (int)notelist[index] % 12;
   switch (pc) {
      case 0:  strcpy(buffer, "c");  break;
      case 1:  strcpy(buffer, "c#");  break;
      case 2:  strcpy(buffer, "d");   break;
      case 3:  strcpy(buffer, "e&");  break;
      case 4:  strcpy(buffer, "e");   break;
      case 5:  strcpy(buffer, "f");   break;
      case 6:  strcpy(buffer, "f#");  break;
      case 7:  strcpy(buffer, "g");   break;
      case 8:  strcpy(buffer, "a&");  break;
      case 9:  strcpy(buffer, "a");   break;
      case 10: strcpy(buffer, "b&");  break;
      case 11: strcpy(buffer, "b");   break;
   }
   strcat(buffer, octbuf);
   strcat(buffer, "/16");
   return buffer;
}



// md5sum: 6960e03ea88018092cee52b4c38e152e henonfile.




[img]http://henon.sapp.org/img3.gif[/img]
black 	=	fixed point ending or goes out of bounds
red 	=	2 point cycle
orange 	=	3 point cycle
yellow 	=	4 point cycle
green 	=	5 point cycle
blue 	=	6 point cycle
indigo 	=	7-11 point cycle
violet 	=	11-20 point cycle
white 	=	no repetition (through 10,000 iterations)
Max4 OS9 Henon Source

Code: Select all

//
// Copyright:     Copyright 2003 Craig Stuart Sapp
// Programmer:    Craig Stuart Sapp <craig@ccrma.stanford.edu>
// Creation Date: Thu Jan 30 02:09:41 PST 2003
// Last Modified: Thu Jan 30 04:36:19 PST 2003
// Filename:      henon.c
// Web Address:   http://peabody.sapp.org/class/dmp2/lab/henon/henon.c
// Syntax:        C; Max4/MSP2 External Object; CodeWarrior 6.0
// OS:	          Mac OS 9; PPC
//
// Description:   Fractal melody generator using the Henon map:
//                   y[n] = 1 + a y[n-1]^2 + b y[n-2]
//

#include "ext.h"

typedef struct {
   t_object max_data;     // Max/MSP data, MUST come first in struct

   double    y;           // current sequence output
   double   yy;           // last sequence output
   double   starty;       // starting y value;
   double   startyy;      // starting yy value;
   double   alpha;        // alpha parameter for henon map
   double   beta;         // beta parameter for henon map
   double   alphamin;     // minimum range for alpha
   double   alphamax;     // maximum range for alpha
   double   betamin;      // minimum range for beta
   double   betamax;      // A now-defunct video tape format
   long     minnote;      // The minimum note number which will be output
   long     maxnote;      // The maximum note number which will be output

   void*    output;       // output bang function pointer
} MyObject;

void* object_data = NULL;

// function declarations:
void*   create_object     (long alphainit, long betainit);
void    InputAlpha        (MyObject* mo, long value);
void    InputAlpha        (MyObject* mo, long value);
void    InputBang         (MyObject* mo);
double  henonmap          (double y, double yy, double alpha, double beta);
double  scaleDataToRange  (long value, double min, double max);
long    midilimit         (long value);


/////////////////////////////////////////////////////////////////////////
//
// Initialization functions
//

//////////////////////////////
//
// main -- called once when the object is created in a patcher window.
//

void main(void) {
   setup((t_messlist**)&object_data, (method)create_object,
         NULL, sizeof(MyObject), NULL, A_DEFLONG, A_DEFLONG, A_NOTHING);
   addbang((method)InputBang);       // inlet 1
   addinx ((method)InputAlpha, 2);   // inlet 2
   addinx ((method)InputBeta,  1);   // inlet 3
}



//////////////////////////////
//
// create_object -- create the data storage for the mydiff object and
//     and setup input 1.
//

void* create_object(long alphainit, long betainit) {
   MyObject* mo = (MyObject*)newobject(object_data);
   mo->starty     = 0.0;
   mo->startyy    = 0.0;
   mo->y          = mo->starty;
   mo->yy         = mo->startyy;
   mo->alphamin   =  -2.0;
   mo->alphamax   =  -1.0;
   mo->betamin    =  -0.25;
   mo->betamax    =   0.25;
   mo->alpha      =   scaleDataToRange(alphainit, mo->alphamin, mo->alphamax);
   mo->beta       =   scaleDataToRange(betainit, mo->betamin, mo->betamax);
   mo->minnote    =  21;
   mo->maxnote    = 109;
   mo->output     = intout(mo);         // outlet 1
   intin(mo, 1);                        // inlet 2
   intin(mo, 2);                        // inlet 3
   return mo;
}


/////////////////////////////////////////////////////////////////////////
//
// Behavior functions
//


//////////////////////////////
//
// InputAlpha -- behavior of the object when a new number comes
//    in on inlet 1.  When a number is received, calculate
//    the alpha parameter for the map, and reset the starting
//    point for the sequence.
//

void InputAlpha(MyObject* mo, long value) {
   mo->alpha = scaleDataToRange(value, mo->alphamin, mo->alphamax);
   mo->y     = mo->starty;
   mo->yy    = mo->startyy;
}



//////////////////////////////
//
// InputBeta -- behavior of the object when a new number comes
//    in on inlet 2.  When a number is received, calculate
//    the beta parameter for the map, and reset the starting
//    point for the sequence.
//

void Input2(MyObject* mo, long value) {
   mo->beta = scaleDataToRange(value, mo->betamin, mo->betamax);
   mo->y    = mo->starty;
   mo->yy   = mo->startyy;
}



//////////////////////////////
//
// InputBang -- behavior of the object when a "bang" message is received.
//

void InputBang(MyObject* mo) {
   double newy;
   long midinote;

   // calculate the next value in the sequence and store it
   newy   = henonmap(mo->y, mo->yy, mo->alpha, mo->beta);
   mo->yy = mo->y;
   mo->y  = newy;

   // scale the new y value to the range from 0 to 127 for output
   midinote = midilimit((int)((newy+1.0)/2.0*127.0 + 0.5));

   // only bang a new output if the new note value is in range
   if ((midinote > mo->minnote) && (midinote < mo->maxnote)) {
      outlet_int(mo->output, midinote);
   }
}


/////////////////////////////////////////////////////////////////////////
//
// Non-interface functions:
//

//////////////////////////////
//
// henonmap -- generate the next value in the Henon map.
//

double henonmap(double y, double yy, double alpha, double beta) {
   return 1.0 + alpha * y * y + beta * yy;
}



//////////////////////////////
//
// midilimit -- limit a number to the range from 0 to 127.
//    if the input is less than 0, return 0.  
//    if the input is greater than 127, return 127.  
//

long midilimit(long value) {
   if (value < 0)     return   0;
   if (value > 127)   return 127;
   return value;
}



//////////////////////////////
//
// scaleDataToRange -- convert a MIDI note number in the range from 0 to 127
//     into a floating-point number in the range from min to max.
//

double scaleDataToRange(long value, double min, double max) {
   return value/127.0 * (max - min) + min;
}
http://henon.sapp.org/
Last edited by WhiteWarlock on Thu Jul 05, 2018 8:36 am, edited 1 time in total.

User avatar
WhiteWarlock
Posts: 1763
Joined: Tue Apr 10, 2018 7:58 am

Re: Noise and Academia

Post by WhiteWarlock » Wed Jul 04, 2018 1:06 pm

busy designing Henon Attractor
yet ponder this...
Image
Image
A Turing Machine is an accepting device which accepts the languages (recursively enumerable set) generated by type 0 grammars. It was invented in 1936 by Alan Turing.
Definition

A Turing Machine (TM) is a mathematical model which consists of an infinite length tape divided into cells on which input is given. It consists of a head which reads the input tape. A state register stores the state of the Turing machine. After reading an input symbol, it is replaced with another symbol, its internal state is changed, and it moves from one cell to the right or left. If the TM reaches the final state, the input string is accepted, otherwise rejected.

A TM can be formally described as a 7-tuple (Q, X, ∑, δ, q0, B, F) where −

Q is a finite set of states

X is the tape alphabet

∑ is the input alphabet

δ is a transition function; δ : Q × X → Q × X × {Left_shift, Right_shift}.

q0 is the initial state

B is the blank symbol

F is the set of final states

Comparison with the previous automaton

The following table shows a comparison of how a Turing machine differs from Finite Automaton and Pushdown Automaton.
Machine Stack Data Structure Deterministic?
Finite Automaton N.A Yes
Pushdown Automaton Last In First Out(LIFO) No
Turing Machine Infinite tape Yes
Example of Turing machine

Turing machine M = (Q, X, ∑, δ, q0, B, F) with

Q = {q0, q1, q2, qf}
X = {a, b}
∑ = {1}
q0 = {q0}
B = blank symbol
F = {qf }

δ is given by −
Tape alphabet symbol Present State ‘q0’ Present State ‘q1’ Present State ‘q2’
a 1Rq1 1Lq0 1Lqf
b 1Lq2 1Rq1 1Rqf

Here the transition 1Rq1 implies that the write symbol is 1, the tape moves right, and the next state is q1. Similarly, the transition 1Lq2 implies that the write symbol is 1, the tape moves left, and the next state is q2.
Time and Space Complexity of a Turing Machine

For a Turing machine, the time complexity refers to the measure of the number of times the tape moves when the machine is initialized for some input symbols and the space complexity is the number of cells of the tape written.

Time complexity all reasonable functions −

T(n) = O(n log n)

TM's space complexity −

S(n) = O(n)
Image
Image
Image
Image


This is has potential for "NOISE" far beyond Eurorack/Synthesis
hmmm
Add some type of randomized duration "Gates"
http://www.thocp.net/biographies/papers ... s_1936.pdf

Image
Image
Last edited by WhiteWarlock on Thu Jul 05, 2018 6:01 am, edited 2 times in total.

User avatar
WhiteWarlock
Posts: 1763
Joined: Tue Apr 10, 2018 7:58 am

Re: Noise and Academia

Post by WhiteWarlock » Wed Jul 04, 2018 9:48 pm

Image
Dual Midi Channel Generative Sequencer
N01ZE HENON ATTRAKTOR
xn+1= 1 - axn2 + bxn
2 "iterations" of formula cross modulating
plus 2x LFO modulating params
generating evolving sequences
includes built in sound engine
works with "Hardware"
will record it using CV/Gate with ARP Solus plus some other gear soon
maybe actually turn on one of the modulars
It's been playing for hours without any crashes :P
Thanks for the Idea making "Esoteric" Henon sequencer....

User avatar
WhiteWarlock
Posts: 1763
Joined: Tue Apr 10, 2018 7:58 am

Re: Noise and Academia

Post by WhiteWarlock » Thu Jul 05, 2018 6:19 am

"Build a Lorenz Attractor"

In 1963 Edward Lorenz published his famous set of coupled nonlinear
first-order ordinary differential equations; they are relatively simple,
but the resulting behavior is wonderfully complex. The equations are:

dx/dt = s(y-x)
dy/dt = rx-y-xz
dz/dt = xy - bz

with suggested parameters s=10, r=28, and b=8/3. The solution executes
a trajectory, plotted in three dimensions, that winds around and around,
neither predictable nor random, occupying a region known as its attractor.
With lots of computing power you can approximate the equations numerically,
and many handsome plots can be found on the web. However, it's rather
easy to implement these equations in an analog electronic circuit, with
just 3 op-amps (each does both an integration and a sum) and two analog
multipliers (to form the products xy and xz).

The Circuit

Here's the circuit:
Image

It's not hard to understand: the op-amps are wired as integrators, with
the various terms that make up each derivative summed at the inputs. The
resistor values are scaled to 1 megohm, thus for example R3 weights the
variable x with a factor of 28 (1M/35.7k); this is combined with -y and
-xz, each with unit weight. (note: the equations on the diagram are
normalized to 0.1V, hence the multiplier scale factor of 100.)


The Output

The circuit just sits there and produces three voltages x(t), y(t), and z(t);
if you hook x and z into a `scope, you get a pattern like this...
Image

...the characteristic "owl's face" of the Lorenz attractor. The curve
plays out in time, sometimes appearing to hesitate as it scales the
boundary and decides which basin to drop back into. The value of C, the
three integrator capacitors, sets the time scale: at 0.47uF it does a
leisurely wander; at 0.1uF it winds around like someone on a mission; and
at 0.002uF it is fiercely busy solving its equations and delighting its
audience.
http://www.malinc.se/m/Lorenz.php
http://physics.ucsc.edu/~drip/programs/lorenz/
Now whatever could that be used for in "NOISE"?


There are three Lorenz equations that comprise the Lorenz Attractor, each of which can be though of as the x, y, or z component of a given three dimensional location in space:
Image

Each of these equations can be read as the 'change in x,y, or z with respect to time'. Thus, each equation is used to calculate how much a given point is changed relative to the previous point, the change dependent upon the elapsed time.

The values a, b, c in the Lorenz equations are constants (for the Lorenz Attractor, a = 10, b = 28, and c = 8/3). These constants, as well as the above equations, can be altered to generate different results. For instance, a value of a = 1 results in a spiral with a single attractor (converging on this attractor), or a value of c = 20 results in a similar pattern given by c = 28, but with more compact orbits. Alternatively, other mathematical equations result in other types of attractors, such as the Henon Map or the Rossler Attractor.

Code: Select all

/*

* Basic Lorenz Attractor code 

*/

double x = 0.1; 

double y = 0;

double z = 0; 

double a = 10.0;

double b = 28.0;

double c = 8.0 / 3.0;

double t = 0.01; 

int lorenzIterationCount = 1000;

int i;

//Iterate and update x,y and z locations

//based upon the Lorenz equations

for ( i = 0; i < lorenzIterationCount; i++ ){

    double xt = x + t * a * (y - x);

    double yt = y + t * (x * (b - z) - y);

    double zt = z + t * (x * y - c * z);

    x = xt;

    y = yt;

    z = zt;

} 

The code above simply loops lorenzIterationCount times, each iteration doing the math to generate the next x,y,z values (the attractor is seeded with values x = 0.1, y = 0, and z = 0). Note that time t is programmed in as 0.01, a relatively arbitrary (and seemingly unit-less) value that is multiplied by the differential equation to generate the change - or delta - in the x,y,z values.

A more comprehensive version written in Java is given below. The Lorenz class, along with the accessory Tuple3d class and Tranform interface (the former for 3-dimensional points and the latter to allow one to change the the mathematics of the attractor with a different implementation of the interface) can be used to iteratively generate the new points based upon the given equations (represented by the Transform implementation).

Code: Select all

/**

 * Interface to transform an object T to a derived form of object T. 

 * @author G Cope

 *

 */

public interface Transform<T> {



	/**

	 * Transforms and returns the transformation of the parameter val.

	 * @param val The object to transform

	 * @return The transformed object. Whether the returned value is the same or a different

	 *  	instance than val is implementation specific.

	 */

	public T transform(T val);

}



/**

 * Class to store 3-dimensional values. 

 * @author G Cope

 *

 */

public class Tuple3d{

	

	public final double x;

	public final double y;

	public final double z;



	/**

	 * Constructs a new Tuple class. 

	 * @param x

	 * @param y

	 * @param z

	 */

	public Tuple3d(double x, double y, double z){

		this.x = x;

		this.y = y;

		this.z = z;

	}

	

	@Override

	public String toString(){

		return "[" + x + ":" + y + ":" + z + "]";

	}

}



/**

 * Attractor based upon the Lorenz equations

 * @author G Cope

 *

 */

public class Lorenz{



	private Tuple3d current = new Tuple3d(0,0,0);

	

	private double a = 10d;

	private double b = 8/3d;

	private double c = 28d;

	

	private double dt = 0.1;

	

	

	/*

	 * The Lorenz equations implemented as a Transform of a Tuple

	 */

	private Transform<Tuple3d> transform = new Transform<Tuple3d>(){



		@Override

		public Tuple3d transform(Tuple3d val) {

			double dxdt = a*(val.y - val.x);

			double dydt = (val.x * (c - val.z) - val.y);

			double dzdt = (val.x*val.y - b * val.z);

			double nx = val.x + dt * dxdt;

			double ny = val.y + dt * dydt;

			double nz = val.z + dt * dzdt ;

			return new Tuple3d(nx, ny, nz);

		}

		

	};



	

	//Cumulative time.

	private double time = 0;

	

	

	/**

	 * Construct a new object with an initial point at the origin and time change of 0.1

	 */

	public Lorenz(){

		this(0,0,0);

	}

	

	/**

	 * Construct a new object with an initial point and default time change of 0.1

	 * @param x

	 * @param y

	 * @param z

	 */

	public Lorenz(double x, double y, double z){

		this(x, y, z, 0.1);

	}

	

	/**

	 * Constructs a new object with an initial point and change in time

	 * @param x

	 * @param y

	 * @param z

	 * @param time

	 */

	public Lorenz(double x, double y, double z, double deltaTime){

		current = new Tuple3d(x, y, z);

		this.dt = deltaTime;

	}

	

	public void setTransform(Transform<Tuple3d> transform){

		this.transform = transform;

	}



	/**

	 * Gets the current cumulative time.

	 * @return

	 */

	public double getCurrentTime(){

		return time;

	}

	

	/**

	 * Sets the delta time parameter

	 * @param dt

	 */

	public void setDt(double dt){

		this.dt = dt;

	}

	

	



	/**

	 * Iterates one step forward in time.

	 */

	public void iterate(){

		time += dt;

		current = transform.transform(current); 

	}

	

	/**

	 * Retrieves the current location. 

	 * @return

	 */

	public Tuple3d getCurrentLocation(){

		return current;

	}

	

}
To use the classes above, one can iteratively call the methods iterate() and getCurrentLocation, the former calculates the next point and the latter allows one to retrieve the new Point. Values from each iteration can be plotted in two or three dimensions - in java one has several options for visualization such as Swing or JOGL. A follow up article will dive into the details, with examples, for how to visualize and render the Lorenz Attractor.


User avatar
WhiteWarlock
Posts: 1763
Joined: Tue Apr 10, 2018 7:58 am

Re: Noise and Academia

Post by WhiteWarlock » Tue Jul 10, 2018 4:38 pm

float g_fScale = 2.0f / 0xffffffff;
int g_x1 = 0x67452301;
int g_x2 = 0xefcdab89;
void whitenoise(
float* _fpDstBuffer, // Pointer to buffer
unsigned int _uiBufferSize, // Size of buffer
float _fLevel ) // Noiselevel (0.0 ... 1.0)
{
_fLevel *= g_fScale;
while( _uiBufferSize-- )
{
g_x1 ^= g_x2;
*_fpDstBuffer++ = g_x2 * _fLevel;
g_x2 += g_x1;
}
}

User avatar
MKULTRA
Posts: 2777
Joined: Sat Sep 13, 2008 6:04 am

Re: Noise and Academia

Post by MKULTRA » Wed Jul 25, 2018 8:54 am

.
Last edited by MKULTRA on Fri Aug 24, 2018 2:02 am, edited 1 time in total.

killing raven sun
Posts: 837
Joined: Wed Jun 13, 2018 2:01 pm

Re: Noise and Academia

Post by killing raven sun » Wed Jul 25, 2018 12:48 pm

of course public schools have a liberal bent, they have to train working drones to fund all the services

but then, robots, and gbi...

i think this lullaby is just about over


Post Reply

Who is online

Users browsing this forum: No registered users and 22 guests