Randomize notes, ability to save note presets

Share your experience, tips & tricks, show off your music. Wishes, ideas and feature suggestions
Post Reply
globalgoon
Posts: 43
Joined: Mon Jan 22, 2007 11:39 am

Randomize notes, ability to save note presets

Post by globalgoon » Mon Dec 03, 2007 4:04 pm

This would be really useful especially since the "CUST" set of notes on the "ARP. CHORD" wheel doesn't get saved when saving a song.

Unless the CUST notes are supposed to be saved?

They don't in ableton anyway

cheers :!:

User avatar
Sebastian@d16
Posts: 1524
Joined: Tue Nov 07, 2006 9:20 pm
Location: Katowice/Poland

Post by Sebastian@d16 » Tue Dec 11, 2007 2:45 pm

I must admit, it's a very interesting idea. We need to note that :)

No, the CUST setting isn't stored within project or as separate preset. But we'll take it into the consideration.

Regards,
Sebastian

globalgoon
Posts: 43
Joined: Mon Jan 22, 2007 11:39 am

Re: Randomize notes, ability to save note presets

Post by globalgoon » Sat Oct 20, 2018 8:05 am

yes this would be great, thanks

globalgoon
Posts: 43
Joined: Mon Jan 22, 2007 11:39 am

Re: Randomize notes, ability to save note presets

Post by globalgoon » Thu Oct 24, 2019 7:41 pm

if anyone has python installed, here is a script I wrote a while ago which generates a bunch of randomised patterns for phoscyon.

Code: Select all

import random
from tkinter import *
import copy

class WordGenerator:
    consonant = ['b','c','d','f','g','h','j','k','l','m','n','p','q','r','s','t','v','w','x','y','z']
    post_consonant_middle = ['','','','h','l','r']
    ending = [
            'an','ang','any','at','ant','ate','are','ax','aul','aria','axanov',
            'en','end','ent','ette','ex','ere', 'eze','exif','ered', 'ezedo',
            'in','ing','ille','illy','int','ilzo','intra',
            'on', 'ood', 'ooced', 'oocle', 'oocin',
            'un','uny','up','ull','uppi','ullo'
              ]
    vowel = [
            'a','aa','ae','ai','ao','au',
            'e','ea','ee','ei','eo','eu',
            'i','ia','ie','io','iu',
            'o','oa','oe','oi','oo','ou',
            'u','ua','ue','ui','uo','uu',
            ]
    random.seed()

    def __init__(self):
        pass

    def create_word(self, length_list):
        s=''
        for length in length_list:
            
            s+= random.choice(self.consonant)
            for i in range(0, length):
                if i%2 == 0:
                    s+= random.choice(self.post_consonant_middle)
                    s+= random.choice(self.vowel)
                else :
                    s+= random.choice(self.consonant)
                    s+= random.choice(self.vowel)

            s+= random.choice(self.ending)
            s+= ' '
        s = s[:-1] 
        return s.capitalize()

class GUI():

   def __init__(self, master, button_callback):
      self.master = master
      master.title('GUI')
      self.label = Label(master, text="Phoscyon Pattern Generator")
      self.label.pack()
      
      self.scale_randomness = Scale(master,
                                    from_=0,
                                    to=100,
                                    orient=HORIZONTAL,
                                    showvalue=1,
                                    label='randomness',
                                    )
          
      self.scale_randomness.pack()

      self.scale_note_density = Scale(master,
                                    from_=1,
                                    to=12,
                                    orient=HORIZONTAL,
                                    showvalue=1,
                                    label='note density',
                                      )
          
      self.scale_note_density.pack()

      self.scale_note_repeat = Scale(master,
                                    from_=0,
                                    to=100,
                                    orient=HORIZONTAL,
                                    showvalue=1,
                                    label='note repeat',
                                     )
          
      self.scale_note_repeat.pack()

      self.button = Button(master,
         text='generate',
         command = button_callback
      )
      self.button.pack()

class Pattern:
    random.seed()
    
    notes = [0,1,2,3,4,5,6,7,8,9,10,11]
    selected_notes = []
    parameters = {'note':0,
                  'octave_up':0,
                  'octave_down':0,
                  'slide':0,
                  'accent':0,
                  'gate':0,
                  'gate_level':0,
                  'accent_level':0,
                  'slide_level':0
                  }
    length = 0

    def __init__(self,length,density):
        self.step = []
        self.length = length
        self.selected_notes = self._get_note_list(density)
        for i in range(length):
            self.step.append( copy.deepcopy(self.parameters) )

    def repeat_parameter(self, parameter, probability):

        def get_previous(currentIndex):
            previousIndex = currentIndex - 1
            if previousIndex < 0 :
                previousIndex = self.length - 1
            return self.step[previousIndex][parameter]
        
        for i in range(self.length):
            if random.random() < probability:
                self.step[i][parameter] = get_previous(i)


    def _get_note_list(self, density):
        my_notes = []
        notes = ['0','1','2','3','4','5','6','7','8','9','10','11']
        random.shuffle(notes)
        for i in range(int(density)):
            my_notes.append(notes[i])
        return my_notes



    def _set_step (self, step_no, param, value):
        self.step[step_no][param] = value



    def _duplicate_steps(self, length, probability):
        for parameter in self.parameters:
            length = random.choice([3,4,6,8,12])
            self._copy_segment(parameter, length, probability)


    def _copy_segment(self, parameter, segment_length, probability):
        for segment in range(segment_length, self.length, segment_length):
            for i in range (0,segment_length):
                if i + segment < self.length:
                    if random.random() < probability:
                        self.step[segment + i][parameter] =  self.step[i][parameter]
    
    def randomize_note_list(self, density):
        self.selected_notes = self._get_note_list(density)
        
    def _randomize(self):
        
        def choose(val_one, val_two, probability):
            if random.random() > probability:
                return val_one
            else:
                return val_two
        
        for i in range(self.length):
            for p in self.parameters:
                if p == 'note':
                    self.step[i][p] = random.choice(self.selected_notes)
                elif p== 'octave_up':
                    self.step[i][p] = choose(0,1,0.3)
                elif p== 'octave_down':
                    self.step[i][p] = choose(0,1,0.3)
                elif p=='gate':
                    self.step[i][p] = choose(0,1,0.7)
                elif p=='accent':
                    self.step[i][p] = choose(0,1,0.4)
                elif p=='slide':
                    self.step[i][p] = choose(0,1,0.4)
                else:
                    self.step[i][p] = random.random()

    def my_randomizer(self, probability = 0):
        self._randomize()
        self._duplicate_steps(self.length, probability)

    def printout(self):
        for i in range(self.length):
            print (self.step[i])


class Phoscyon:
    
    def __init__(self, filename):
        self.filename = filename

    def open_file(self):
        self.file = open(self.filename + ".phptrb", "w")
        
    def write_file_header(self):
        self.file.write('<?xml version="1.0" encoding="UTF-8"?>\n')
        self.file.write('<PatternBank>\n')

    def write_file_pattern_header(self, name, length, shuffle, tempo):
        s = '<Pattern application="Phoscyon" '
        s += 'name="' + str(name) + '" '
        s += 'length="' + str(length) + '" '
        s += 'shuffle="' + str(shuffle) + '" '
        s += 'tempo="' + str(tempo) + '" '
        s += '>\n'
        self.file.write(s)

    def write_step_to_file(self,note,octave_up,octave_down,gate,accent,slide,gate_level,accent_level,slide_level) :
        s = '<Step '
        s += 'note="' + str(note) + '" '
        s += 'octaveUp="' + str(octave_up) + '" '
        s += 'octaveDown="' + str(octave_down) + '" '
        s += 'gate="' + str(gate) + '" '
        s += 'accent="' + str(accent) + '" '
        s += 'slide="' + str(slide) + '" '
        s += 'gateLevel="' + str(gate_level) + '" '
        s += 'accentLevel="' + str(accent_level) + '" '
        s += 'slideLevel="' + str(slide_level) + '" '
        s += '/>\n'
        self.file.write(s)

    def write_file_pattern_footer(self):
        self.file.write('</Pattern>\n')

    def write_file_footer(self):
        self.file.write('</PatternBank>\n')

    def close_file(self):
        self.file.close()


def generate():
    print ('start')
    wordgenerator = WordGenerator()
    pattern = Pattern(16,0.5)
    filename = wordgenerator.create_word([5,1,2])
    phoscyon = Phoscyon(filename)
    phoscyon.open_file()
    phoscyon.write_file_header()

    for i in range(64):
 
        pattern.randomize_note_list(gui.scale_note_density.get())
        pattern.my_randomizer(1-(gui.scale_randomness.get()/100) )
        pattern.repeat_parameter('note', gui.scale_note_repeat.get()/100)

            
        phoscyon.write_file_pattern_header(wordgenerator.create_word([1,3]), 16, 0, 120)
        for step in pattern.step:
            
            phoscyon.write_step_to_file(
                step['note'],
                step['octave_up'],
                step['octave_down'],
                step['gate'],
                step['accent'],
                step['slide'],
                step['gate_level'],
                step['accent_level'],
                step['slide_level']
                )
        phoscyon.write_file_pattern_footer()

    phoscyon.write_file_footer() 
    phoscyon.close_file()
    print (filename + ' completed')

#start
root=Tk()
gui = GUI(root, generate)
root.mainloop()

                                 

Post Reply