Author Topic: Texture note generator  (Read 293 times)

sonora

  • Full Member
  • ***
  • Posts: 12
    • View Profile
Texture note generator
« on: October 24, 2019, 10:17:53 PM »
Any advice for routines in C-phyton basic ecc. that can generate note score files for texture?

ArcherCDP

  • Full Member
  • ***
  • Posts: 19
    • View Profile
Re: Texture note generator
« Reply #1 on: November 02, 2019, 11:23:52 AM »
 :)

You asked:  "Any advice for routines in C, Python, Basic etc. that can generate note score files for texture?"

The answer is very much Yes.  This raises a topic in which I am very interested, namely the use of scripting to create files for the various CDP programs.  Such scripts can have algorithmic features that would be tedious if not impossible to duplicate by hand.  It is a very powerful aspect of the CDP software that the programs can be run from a command line.  I believe that the development of such scripts can form an important part of CDP's future and am working to this end myself. 

The method for doing so was established a along time ago by Paul Rhys.  He wrote a perper and a script in Richard Orton's 'Tabula Vigilans' scripting language to create Csound score files.  The overall procedure is straightforward:

- establish arrays to hold data
- if applicable, open a data file for reading and read the data into an array
- manipulate this data or create new data by a customised procedure
- optional:  preview the result via MIDI playback
- open a file for writing
- write the data to this file in the format required by the CDP program

Here is a write procedure for a TEXTURE note data file using Tabula Vigilans.  The write functions in Tabula Vigilans are stori (write an integer), store (write a floating point value) and storstr (write text).  They need to be replaced by the appropriate write function in the scripting language being used.  It is assumed that variables would replace most of these numbers.  Some variables are shown below.  Note that steps 1 and 2 are done first and separately:  they are written only once, whereas the procedure for the data lines is called for each line -- the changing values are fed into a Play procedure in the same pass in order to audition them.  This file is for TEXTURE TIMED.  Comments here begin with '//'.

1. write the nominal pitch value:        stori 60
2. write the number of lines to follow:  storstr #
                stori 21  (for a data loop of 21 items)
3. write the data lines, separating data with spaces or tabs:
write_ndfTimedfiles()   //MODE 4: outfndftxTimed.txt, outftxpch.brk,
{         //  outftxvelocities.brk

  //this section stores the data lines for a TEXTURE TIMED ndf
  //Format:  time 1 0 0 0
  //This is simplified when variables and text can be written in the
  //  same line, a feature in C & Python, and coming soon in Tabula Vigilans
  //  thanks to John Ffitch
  store eventtime   //write the event start time
  storstr "\t"      //write a tab
  stori 1      //write the required but non-functional '1'
  storstr "\t"      //write a tab
  stori 0      //write a '0'
  storstr "\t"      //write a tab
  stori 0      //write a '0'
  storstr "\t"      //write a tab
  stori 0      //write a '0'
  storstr "\n"      //write a newline
 
  //this section writes a separate pitch breakpoint file for the pitch
  //     parameter on the command line (optional)
  store eventtime   //write the event (start) time
  storstr "\t  "   //write a tab
  store pch      //write the pitch value
  storstr "\n"      //write a newline
 
  //this section writes a separate breakpoint file for velocity
  store, eventtime   //write the event start time
  storstr "\t"   //write a tab
  store vel      //write the velocity value
  storstr "\n"     //write a newline

  eventtime += dur   //update the event time with the event duration
}

(Tabula Vigilans syntax is a slightly more complicated than what is shown because multiple output files are involved.)

The same basic procedure is followed for other types of note data file, including adding a Harmonic Set option.  (The note data file for TEXTURE SIMPLE Mode 5 has only the nominal reference pitch(es).)

This is a sample (MIDI) Play routine as used in Tabula Vigilans:
play()
{
    xx = try(midiout chan, pch, vel, dur)    //play MIDI output
      if(xx > 0) {
        d += 1                //do nothing dummy
      } else {
        messag1 "\nmidiout has encountered a problem"
      }
    wait dur
 }

I would then create a batch file to run TEXTURE TIMED with this (named) ndf file and, optionally, with the pitch and velocity breakpoint files made at the same time.  This creates the rhythm defined in the ndf with one or more soundfiles.  Here is an example batch file:

*****
rem TEXTURE TIMED (if > 1 sfile input, hand-edit ndf to add more nominal pitches)
rem .. mode inf(s) outf ndffile outdur skiptime snd1st sndlast
rem   mingain maxgain mindur maxdur minpch maxpch -aatten -pposition -sspread

texture timed 5 tshc1g.wav r7tshtimed.wav outfndftxtimed.txt 10 0.93333 1 1 outfvelocities.brk outfvelocities.brk 0.5 1 outftxpch.brk outftxpch.brk -a0.9 -p0.5 -s0  -w

pvplay -i r7tshtimed.wav

rem Delete output soundfile before running again.
*****

There follows a complete template script for creating a Csound score file, based on Paul Rhys' original concept.  It shows how the various procedures are put together.


//cssctmpl.tv - TV script template for writing Csound score files

table  FREQS[12]

start()
{
   if(init == 0) {
      call initialise()
   }

   call headings()

   call sample_process()

   call ending()
loop
}


headings()
{
   storefile "acsscore.sco"         //filename
   storstr ";acsscore.sco - a Csound score file\n" //title banner
   storstr ";\ttemplate example written with TV\n" //purpose
   storstr "f1 0 1024 10 1 0 0 \n\n"      //an f statement
   storstr ";instr\tstime\tdur\tamp\tfreq\n"   //pfield names
}


sample_process()
{
   for(i=0; i < 12; i += 1) {
      storstr "i"
      stori instr
      storstr "\t"

      store stime
      stime += 0.75
      storstr "\t"

      store dur
      dur = random(0.25, 1.5)
      storstr "\t"

      stori amp
      if(i < 6) {
         amp += 1000
      } else {
      amp -= 1000
      }
      storstr "\t"

      freq = FREQS[ndx++] //UP: C-Eb-G-A-Bb-C Dwn: C-B-Ab-G-F#-Db
      store freq
      storstr "\n"      //create new line of score data
   }
}


ending()
{
   storstr "e"
   end
}

I hope this goes some way to answering the question.

Archer

sonora

  • Full Member
  • ***
  • Posts: 12
    • View Profile
Re: Texture note generator
« Reply #2 on: November 21, 2019, 10:11:25 AM »
thanks Archer but is it possible to try tabula vigilans?