electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Articles  |  Radio
 |  Media  |  Forum  |  Links  |  Store
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks GalleryGallery 
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
 Forum index » DIY Hardware and Software » ChucK programming language
I'm Back
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [7 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
ausz99



Joined: Feb 25, 2008
Posts: 9
Location: UK
Audio files: 1

PostPosted: Wed Apr 30, 2008 5:08 am    Post subject: I'm Back Reply with quote  Mark this post and the followings unread

Hi guys. It's been a long time since i've been on the forum and even longer since i've been playing with chuck. Just wondering if you could have a look at this coding for me. It's trying to get a SinOsc to play a harmonic minor scale but alas i've forgotten how to make use of arrays.

Code:
SinOsc s => dac;

//Harmonic minor scale

261.626 =>float C1; //Had to create C1 and C2 because
293.665 =>float D;  //otherwise C would have been assigned
311.127 =>float E; //to two notes an octave apart.
349.228 =>float F;
391.995 =>float G;
415.305 =>float A;
246.942=> float B;
523.251 =>float C2;

[ C1, D, E, F, G, A, B, C2 ] @=> int bassline[];

bassline[] => s.freq


Don't laugh at it lol coz i have forgotten a lot. I handed in my project and haven't really touched chuck since and want to get back into it now.

Cheers for any help

Ausz99
Back to top
View user's profile Send private message
Inventor



Joined: Oct 13, 2007
Posts: 1700
Location: Florida, USA
Audio files: 67

PostPosted: Wed Apr 30, 2008 6:06 am    Post subject: Reply with quote  Mark this post and the followings unread

Try this:

Code:
SinOsc s => dac;

//Harmonic minor scale

261.626 =>float C1; //Had to create C1 and C2 because
293.665 =>float D;  //otherwise C would have been assigned
311.127 =>float E; //to two notes an octave apart.
349.228 =>float F;
391.995 =>float G;
415.305 =>float A;
246.942=> float B;
523.251 =>float C2;

[ C1, D, E, F, G, A, B, C2 ] @=> float bassline[];

for (0 => int i; i <8> s.freq;
    250::ms => now;
}


I changed your array to type float, set up a for loop, indexed the array, and put in a time delay for each note.

Welcome back, and by the way you can post to the ChucK forum under DIY now. Cheers.

_________________
For those about to ChucK, we salute you! - Ge Wang
Let's make noise for peace! - kijjaz
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Blue Hell
Site Admin


Joined: Apr 03, 2004
Posts: 11968
Location: Netherlands, Enschede
Audio files: 28
G2 patch files: 295

PostPosted: Wed Apr 30, 2008 7:23 am    Post subject: Reply with quote  Mark this post and the followings unread

I Moved this thread to the ChucK section.
_________________
Jan
Back to top
View user's profile Send private message Visit poster's website
ausz99



Joined: Feb 25, 2008
Posts: 9
Location: UK
Audio files: 1

PostPosted: Mon May 05, 2008 4:16 am    Post subject:   Reply with quote  Mark this post and the followings unread

Cheers Inventor

Code:
SinOsc s => dac;

//Harmonic minor scale

261.626 =>float C1; //Had to create C1 and C2 because
293.665 =>float D;  //otherwise C would have been assigned
311.127 =>float E; //to two notes an octave apart.
349.228 =>float F;
391.995 =>float G;
415.305 =>float A;
246.942=> float B;
523.251 =>float C2;

[ C1, D, E, F, G, A, B, C2 ] @=> float bassline[];

for (0 => int i; i <8> s.freq;
    250::ms => now;
}


Unfortunatly this code doesn't work, i think it's something to do with brackets on the "for" loop at the end, i'm gonna have a tinker and if i get it to work i'll post it here

Ausz99
Back to top
View user's profile Send private message
Inventor



Joined: Oct 13, 2007
Posts: 1700
Location: Florida, USA
Audio files: 67

PostPosted: Mon May 05, 2008 5:00 am    Post subject: Reply with quote  Mark this post and the followings unread

Code:
SinOsc s => dac;

//Harmonic minor scale

261.626 =>float C1; //Had to create C1 and C2 because
293.665 =>float D;  //otherwise C would have been assigned
311.127 =>float E; //to two notes an octave apart.
349.228 =>float F;
391.995 =>float G;
415.305 =>float A;
246.942=> float B;
523.251 =>float C2;

[ C1, D, E, F, G, A, B, C2 ] @=> float bassline[];

for (0 => int i; i < 8; i++ ) {
    bassline[i] =>s.freq;
    250::ms => now;
}


There, try that. I forgot to check the box for "Disable HTML in this post" and the forum software misinterpreted the "<" for html. This one should work fine, I tested it.

_________________
For those about to ChucK, we salute you! - Ge Wang
Let's make noise for peace! - kijjaz
Back to top
View user's profile Send private message Send e-mail Visit poster's website
kijjaz



Joined: Sep 20, 2004
Posts: 568
Location: bangkok, thailand
Audio files: 2

PostPosted: Mon May 05, 2008 11:09 am    Post subject: Reply with quote  Mark this post and the followings unread

I propose some adjustments to the original patch:

Code:
SinOsc s => dac;

//Harmonic minor scale
[261.626, 293.665, 311.127, 349.228, 391.995, 415.305, 493.884, 523.251] @=> float ScaleFreq1[];
0 => int Do;
1 => int Re;
2 => int Mi;
3 => int Fa;
4 => int So;
5 => int La;
6 => int Ti;

[Do, Re, Mi, Fa, So, La, Ti, Do + 7, So, Ti - 7, Do] @=> int bassline[];

int octave;
for (0 => int i; i < bassline.cap(); i++ )
{
    0 => octave;
    bassline[i] => int GetNote;
    while(GetNote < 0)
    {
        octave--;
        7 +=> GetNote;
    }
    while(GetNote >= 7)
    {
        octave++;
        7 -=> GetNote;
    }
    ScaleFreq1[GetNote] * Math.pow(2, octave) => s.freq;
    250::ms => now;
}


this works quite the same but added some convenience.
notes can be called by Do Re Mi..
and number of tone can be added or subtracted.
for example, adding with 7 makes it jump to another octave.
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Inventor



Joined: Oct 13, 2007
Posts: 1700
Location: Florida, USA
Audio files: 67

PostPosted: Mon May 05, 2008 1:25 pm    Post subject: Reply with quote  Mark this post and the followings unread

Crank it up, kijjaz! Play that funky music kijjaz! Haha. Nice changes.
_________________
For those about to ChucK, we salute you! - Ge Wang
Let's make noise for peace! - kijjaz
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [7 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
 Forum index » DIY Hardware and Software » ChucK programming language
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum
Once You Know, You Newegg

Please support our site. If you click through and buy from
our affiliate partners, we earn a small commission.


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003, 2004, 2005, 2006 and 2007 by electro-music.com