Discussion

You need to log in to create posts and topics.

Various questions (some possibly newbie)

  1. Note: Using Windows 7 64bit, Python 3.6 Win 32,SuperCollider-3.8., FoxDot Version: 0.4.14
  2. Is there a FoxDot command to show the version?
  3. When assigning pitches in an array, like: p1 >> pads([0,1,2]), is it possible to specify accidentals (sharps  - # and flats - b)?
  4. When working with pitches is there anyway to represent the array values as 1, 2, 3 (let's say we are in the key of C. 1, 2, 3, 4 would be C, D, E, D rather than o, 1, 2, 3? Then you can represent chords in a more musically recognizable manner: 1, 3, 5, 7 would be a C Major 7 rather than 0, 2, 4, 5. (And with accidentals, you specify 1, b3, 5, 7 a C minor 7th chord).
  5. How are rests expressed : p1 >> pads([0,1,2], dur=[1,1/2,1/2], oct=6, pan=[1,-1])? In the dur array?
  6. And now my newbie lack of Python skills: I had wanted to write some code to somehow loop through all of the (relevant) SynthDefs and play each one with a player object. I thought it would be a straightforward iteration loop but it seems more complicated than that. When you list the SynthDefs using print(SynthDefs) that it is printing out the keys for the SynthDefs. Also a SynthDef is an object and not a string so that seems to complicate matters for my skill level (or lack thereof)
  7. When I try this command from the FoxDot Tutorial 1: Basics video - p3 >>play("x-o{-[--][-o]}")  I get the following errors:
Traceback (most recent call last):
 File "C:\Users\pp0rter\AppData\Local\Programs\Python\Python36-32\lib\site-packages\FoxDot\lib\Code\main_lib.py", line 106, in __call__
 exec(self._compile(code), self.namespace)
 File "FoxDot", line 1, in <module>
 """
 File "C:\Users\pp0rter\AppData\Local\Programs\Python\Python36-32\lib\site-packages\FoxDot\lib\Players.py", line 352, in __rshift__
 self.update(other.name, other.degree, **other.kwargs)
 File "C:\Users\pp0rter\AppData\Local\Programs\Python\Python36-32\lib\site-packages\FoxDot\lib\Players.py", line 777, in update
 setattr(self, "degree", degree if len(degree) > 0 else " ")
 File "C:\Users\pp0rter\AppData\Local\Programs\Python\Python36-32\lib\site-packages\FoxDot\lib\Players.py", line 436, in __setattr__
 for item in value:
 File "C:\Users\pp0rter\AppData\Local\Programs\Python\Python36-32\lib\site-packages\FoxDot\lib\Patterns\Main.py", line 223, in __iter__
 yield self.getitem(i)
 File "C:\Users\pp0rter\AppData\Local\Programs\Python\Python36-32\lib\site-packages\FoxDot\lib\Patterns\Main.py", line 199, in getitem
 val = val.getitem(j)
 File "C:\Users\pp0rter\AppData\Local\Programs\Python\Python36-32\lib\site-packages\FoxDot\lib\Patterns\Main.py", line 905, in getitem
 value = self.func(index)
 File "C:\Users\pp0rter\AppData\Local\Programs\Python\Python36-32\lib\site-packages\FoxDot\lib\Patterns\Generators.py", line 65, in func
 value = self.choose()
 File "C:\Users\pp0rter\AppData\Local\Programs\Python\Python36-32\lib\site-packages\FoxDot\lib\Patterns\Generators.py", line 60, in choose
 return self.data[self.choice(xrange(self.MAX_SIZE))]
NameError: name 'xrange' is not defined

Hi pp0rter, thanks for getting in touch.

  • The easiest way to check the version is to run "pip show FoxDot" from the command prompt.
  • Right now if you want to add a sharp or flat you can specify the pitch as a floating point number. e.g. 0.5 would be C# in the default scale. I get this question a lot and I'm not sure this is the best way to address the problem. For instance using a pitch value of 2.5 in the default scale gives you the note between E and F where there is no middle semitone.
  • Again, this issue crops up a lot. In most programming languages arrays start at 0 but in music they start at 1 i.e. the 1st note of the C Major scale is C, not the 0th. As a work around you could subtract 1 from all the values by adding negative 1 outside of your player object like so:
p1 >> pluck([1,3,5,8]) + (-1)
  • I need to fix something with adding negative numbers apparently...
  • Rests can be added by creating a "rest" object in the "dur" array like so:
p1 >> pluck([0,1,2,3], dur=[1,1,rest(1)])
  • Using loops can be tricky in live coding as Python will loop through everything as fast as possible and using "sleep" will freeze the editor. First of all, though, to get the SynthDef object you access it via the object "SynthDefs", which is a subclass of the Python dictionary. A dictionary is basically a list of paired values, with one identifier called a "key". The name of the SynthDefs are the identifiers, which are what you see when you "print(SynthDefs)". So to access the object itself you use SynthDefs[name]. So here's what I imagine you would like to do:
p1 >> pads() # Start the Synth playing

for synth in SynthDefs:
    if synth != "loop": # The "loop" SynthDef requires a filename argument
        print(synth)
        p1 >> SynthDefs[synth]()
        sleep(2)
  • This will play all the  SynthDefs in turn for 2 seconds but will freeze the interpreter and won't print the name of the SynthDef. To get around this you'll need to use something called "temporal recursion" where we write a function that calls itself in the future. So here's our function:
def test_synths(i=0):
    # Get the synth
    allsynths = list(SynthDefs.keys())
    # Stop calling the function when we run out of Synths
    if i > len(allsynths):
        return
    synthName = allsynths[i]
    synthObj = SynthDefs[synthName]
    # Ignore sample based players
    if synthName not in ("loop", "play1", "play2"):
        print(synthName)
        p1 >> synthObj()
        # Call the synth 4 beats in the future
        Clock.future(4, lambda: test_synths(i+1))
    else:
        # Call the function immediately if it's a sample player
        test_synths(i + 1)
  • Then just call run "test_synths()" in FoxDot and it will start looping over the different SynthDefs. Sorry if it's a bit complicated!
  • If you upgrade to the latest version of FoxDot by opening the  command prompt and running "pip install FoxDot --upgrade" you should find the "xrange" error has now been fixed.

Hope this is helpful, if you have any  other questions just ask!

I like the -1 idea. Programmatically, it should stay 0 index based.

"Temporal recursion"?  - Wow! I do like the sound of that!

Great answers. Thanks!