Csound Csound-dev Csound-tekno Search About

[Csnd] Chord OpCode?

Date2012-11-25 22:45
FromRoger Kelly
Subject[Csnd] Chord OpCode?
I am hoping to find some opcode or UDO that given a string name of a chord can render back the sequence of notes.

Does anything like this exist for Csound?

For example ("maj") -> [60,63,65] for example

Date2012-11-25 23:29
FromMichael Gogins
SubjectRe: [Csnd] Chord OpCode?
CsoundAC, an optional component of Csound, has such facilities which
are under active development. They are in the API documentation.

Regards,
Mike

On Sun, Nov 25, 2012 at 5:45 PM, Roger Kelly  wrote:
> I am hoping to find some opcode or UDO that given a string name of a chord
> can render back the sequence of notes.
>
> Does anything like this exist for Csound?
>
> For example ("maj") -> [60,63,65] for example



-- 
Michael Gogins
Irreducible Productions
http://www.michael-gogins.com
Michael dot Gogins at gmail dot com

Date2012-11-26 00:05
Frompeiman khosravi
SubjectRe: [Csnd] Chord OpCode?
Surely that's 60, 64, 67? :p

It would be nice to have an opcode like the 'coll' object in max.

So a text like this could be read from the disk.

maj, 60 64 67;
min, 60 63 67;
3, 1 2 3 4;

Then calling the index 'maj' would return the array [60 64 67]. This would also allow an easy way of creating several tables in a text file (by reading arrays into tables). Or even lists of notes to be triggered in real time.

P

On 25 November 2012 22:45, Roger Kelly <loraxman@gmail.com> wrote:
I am hoping to find some opcode or UDO that given a string name of a chord can render back the sequence of notes.

Does anything like this exist for Csound?

For example ("maj") -> [60,63,65] for example


Date2012-11-26 09:01
Fromjoachim heintz
SubjectRe: [Csnd] Chord OpCode?
well, i think this is actually already possible in csound:
1) you can store tables in a text file and read them via GEN23
2) john ffitch has recently written opcodes for reading files and 
returning the lines as strings:
Sres readf(i) ifilname
using this opcode, it should be possible to do something similar to the 
coll object in max - not in the same syntax but in a "csoundish" way.

@ roger: do you mean something like this?


   opcode Triad, iii, S
Sname      xin
iMaj       strcmp     "maj", Sname
iMin       strcmp     "min", Sname
iPrim      =          60
iQuint     =          67
  if iMaj == 0 then
iTer       =          64
  elseif iMin == 0 then
iTer       =          63
  endif
            xout       iPrim, iTer, iQuint
   endop
   instr 1
Sname      strget     p4
ia, ib, ic Triad      Sname
            print      ia, ib, ic
   endin


i1 0 0 "maj"
i1 0 0 "min"



best -
	joachim


Am 26.11.2012 01:05, schrieb peiman khosravi:
> Surely that's 60, 64, 67? :p
>
> It would be nice to have an opcode like the 'coll' object in max.
>
> So a text like this could be read from the disk.
>
> maj, 60 64 67;
> min, 60 63 67;
> 3, 1 2 3 4;
>
> Then calling the index 'maj' would return the array [60 64 67]. This
> would also allow an easy way of creating several tables in a text file
> (by reading arrays into tables). Or even lists of notes to be triggered
> in real time.
>
> P
>
> On 25 November 2012 22:45, Roger Kelly  > wrote:
>
>     I am hoping to find some opcode or UDO that given a string name of a
>     chord can render back the sequence of notes.
>
>     Does anything like this exist for Csound?
>
>     For example ("maj") -> [60,63,65] for example
>
>

Date2012-11-26 09:11
Frompeiman khosravi
SubjectRe: [Csnd] Chord OpCode?
Thanks Joachim,

Yes tables can be saved to file but that's not really for manually editing. Coll is more generic and allows one array per line, which is more readable.

Your example works but you have to predefine every index symbol in the score. The whole point of coll is that it saves a lot of unnecessary hard-coding in the patch. Mhh unless there is a string matching opcode. I'll check it out.  

Thanks
Peiman

On 26 November 2012 09:01, joachim heintz <jh@joachimheintz.de> wrote:
well, i think this is actually already possible in csound:
1) you can store tables in a text file and read them via GEN23
2) john ffitch has recently written opcodes for reading files and returning the lines as strings:
Sres readf(i) ifilname
using this opcode, it should be possible to do something similar to the coll object in max - not in the same syntax but in a "csoundish" way.

@ roger: do you mean something like this?
<CsoundSynthesizer>
<CsInstruments>
  opcode Triad, iii, S
Sname      xin
iMaj       strcmp     "maj", Sname
iMin       strcmp     "min", Sname
iPrim      =          60
iQuint     =          67
 if iMaj == 0 then
iTer       =          64
 elseif iMin == 0 then
iTer       =          63
 endif
           xout       iPrim, iTer, iQuint
  endop
  instr 1
Sname      strget     p4
ia, ib, ic Triad      Sname
           print      ia, ib, ic
  endin
</CsInstruments>
<CsScore>
i1 0 0 "maj"
i1 0 0 "min"
</CsScore>
</CsoundSynthesizer>

best -
        joachim


Am 26.11.2012 01:05, schrieb peiman khosravi:
Surely that's 60, 64, 67? :p

It would be nice to have an opcode like the 'coll' object in max.

So a text like this could be read from the disk.

maj, 60 64 67;
min, 60 63 67;
3, 1 2 3 4;

Then calling the index 'maj' would return the array [60 64 67]. This
would also allow an easy way of creating several tables in a text file
(by reading arrays into tables). Or even lists of notes to be triggered
in real time.

P

On 25 November 2012 22:45, Roger Kelly <loraxman@gmail.com
<mailto:loraxman@gmail.com>> wrote:

    I am hoping to find some opcode or UDO that given a string name of a
    chord can render back the sequence of notes.

    Does anything like this exist for Csound?

    For example ("maj") -> [60,63,65] for example




Send bugs reports to the Sourceforge bug tracker
           https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"



Date2012-11-26 11:15
Fromjoachim heintz
SubjectRe: [Csnd] Chord OpCode?
hi peiman -

i do certainly agree that something like a hash table would be nice to 
have in csound.

but meanwhile there are "csoundish" solutions, i think, which may look 
uglier, but are they really more complicate? for instance:



   instr 1
print p4, p5, p6
   endin


#define maj #60 64 67#
#define min #60 63 67#
i1 0 0 $maj.
i1 0 0 $min.



all the #define ... statements can be collected in a seperate file, and 
included by
#include "my_chords.txt" or something like this.

as far as i understand roger's request, in this case this can offer the 
same functionality as a Max coll object, just with another syntax.

what do you think?

all best -

	joachim


Am 26.11.2012 10:11, schrieb peiman khosravi:
> Thanks Joachim,
>
> Yes tables can be saved to file but that's not really for manually
> editing. Coll is more generic and allows one array per line, which is
> more readable.
>
> Your example works but you have to predefine every index symbol in the
> score. The whole point of coll is that it saves a lot of unnecessary
> hard-coding in the patch. Mhh unless there is a string matching opcode.
> I'll check it out.
>
> Thanks
> Peiman
>
> On 26 November 2012 09:01, joachim heintz  > wrote:
>
>     well, i think this is actually already possible in csound:
>     1) you can store tables in a text file and read them via GEN23
>     2) john ffitch has recently written opcodes for reading files and
>     returning the lines as strings:
>     Sres readf(i) ifilname
>     using this opcode, it should be possible to do something similar to
>     the coll object in max - not in the same syntax but in a "csoundish"
>     way.
>
>     @ roger: do you mean something like this?
>     
>     
>        opcode Triad, iii, S
>     Sname      xin
>     iMaj       strcmp     "maj", Sname
>     iMin       strcmp     "min", Sname
>     iPrim      =          60
>     iQuint     =          67
>       if iMaj == 0 then
>     iTer       =          64
>       elseif iMin == 0 then
>     iTer       =          63
>       endif
>                 xout       iPrim, iTer, iQuint
>        endop
>        instr 1
>     Sname      strget     p4
>     ia, ib, ic Triad      Sname
>                 print      ia, ib, ic
>        endin
>     
>     
>     i1 0 0 "maj"
>     i1 0 0 "min"
>     
>     
>
>     best -
>              joachim
>
>
>     Am 26.11.2012 01:05, schrieb peiman khosravi:
>
>         Surely that's 60, 64, 67? :p
>
>         It would be nice to have an opcode like the 'coll' object in max.
>
>         So a text like this could be read from the disk.
>
>         maj, 60 64 67;
>         min, 60 63 67;
>         3, 1 2 3 4;
>
>         Then calling the index 'maj' would return the array [60 64 67]. This
>         would also allow an easy way of creating several tables in a
>         text file
>         (by reading arrays into tables). Or even lists of notes to be
>         triggered
>         in real time.
>
>         P
>
>         On 25 November 2012 22:45, Roger Kelly          
>         >> wrote:
>
>              I am hoping to find some opcode or UDO that given a string
>         name of a
>              chord can render back the sequence of notes.
>
>              Does anything like this exist for Csound?
>
>              For example ("maj") -> [60,63,65] for example
>
>
>
>
>     Send bugs reports to the Sourceforge bug tracker
>     https://sourceforge.net/__tracker/?group_id=81968&atid=__564599
>     
>     Discussions of bugs and features can be posted here
>     To unsubscribe, send email sympa@lists.bath.ac.uk
>      with body "unsubscribe csound"
>
>

Date2012-11-26 11:36
Frompeiman khosravi
SubjectRe: [Csnd] Chord OpCode?
Hi Joachim,

Yes this solution is a good one, at least as far as Roger's task goes. But for other purposes this would be really cumbersome: imagine lines and lines of number to represent frequency partials and so on...  

Best,
Peiman 

On 26 November 2012 11:15, joachim heintz <jh@joachimheintz.de> wrote:
hi peiman -

i do certainly agree that something like a hash table would be nice to have in csound.

but meanwhile there are "csoundish" solutions, i think, which may look uglier, but are they really more complicate? for instance:

<CsoundSynthesizer>
<CsInstruments>
  instr 1
print p4, p5, p6
  endin
</CsInstruments>
<CsScore>
#define maj #60 64 67#
#define min #60 63 67#
i1 0 0 $maj.
i1 0 0 $min.
</CsScore>
</CsoundSynthesizer>

all the #define ... statements can be collected in a seperate file, and included by
#include "my_chords.txt" or something like this.

as far as i understand roger's request, in this case this can offer the same functionality as a Max coll object, just with another syntax.

what do you think?

all best -

        joachim


Am 26.11.2012 10:11, schrieb peiman khosravi:
Thanks Joachim,

Yes tables can be saved to file but that's not really for manually
editing. Coll is more generic and allows one array per line, which is
more readable.

Your example works but you have to predefine every index symbol in the
score. The whole point of coll is that it saves a lot of unnecessary
hard-coding in the patch. Mhh unless there is a string matching opcode.
I'll check it out.

Thanks
Peiman

On 26 November 2012 09:01, joachim heintz <jh@joachimheintz.de
<mailto:jh@joachimheintz.de>> wrote:

    well, i think this is actually already possible in csound:
    1) you can store tables in a text file and read them via GEN23
    2) john ffitch has recently written opcodes for reading files and
    returning the lines as strings:
    Sres readf(i) ifilname
    using this opcode, it should be possible to do something similar to
    the coll object in max - not in the same syntax but in a "csoundish"
    way.

    @ roger: do you mean something like this?
    <CsoundSynthesizer>
    <CsInstruments>
       opcode Triad, iii, S
    Sname      xin
    iMaj       strcmp     "maj", Sname
    iMin       strcmp     "min", Sname
    iPrim      =          60
    iQuint     =          67
      if iMaj == 0 then
    iTer       =          64
      elseif iMin == 0 then
    iTer       =          63
      endif
                xout       iPrim, iTer, iQuint
       endop
       instr 1
    Sname      strget     p4
    ia, ib, ic Triad      Sname
                print      ia, ib, ic
       endin
    </CsInstruments>
    <CsScore>
    i1 0 0 "maj"
    i1 0 0 "min"
    </CsScore>
    </CsoundSynthesizer>

    best -
             joachim


    Am 26.11.2012 01:05, schrieb peiman khosravi:

        Surely that's 60, 64, 67? :p

        It would be nice to have an opcode like the 'coll' object in max.

        So a text like this could be read from the disk.

        maj, 60 64 67;
        min, 60 63 67;
        3, 1 2 3 4;

        Then calling the index 'maj' would return the array [60 64 67]. This
        would also allow an easy way of creating several tables in a
        text file
        (by reading arrays into tables). Or even lists of notes to be
        triggered
        in real time.

        P

        On 25 November 2012 22:45, Roger Kelly <loraxman@gmail.com
        <mailto:loraxman@gmail.com>
        <mailto:loraxman@gmail.com <mailto:loraxman@gmail.com>>> wrote:

             I am hoping to find some opcode or UDO that given a string
        name of a
             chord can render back the sequence of notes.

             Does anything like this exist for Csound?

             For example ("maj") -> [60,63,65] for example




    Send bugs reports to the Sourceforge bug tracker
    https://sourceforge.net/__tracker/?group_id=81968&atid=__564599

    <https://sourceforge.net/tracker/?group_id=81968&atid=564599>
    Discussions of bugs and features can be posted here
    To unsubscribe, send email sympa@lists.bath.ac.uk
    <mailto:sympa@lists.bath.ac.uk> with body "unsubscribe csound"




Send bugs reports to the Sourceforge bug tracker
           https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"