electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Articles  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links  |  Store
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks
 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
problems with sync
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [12 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
majutsu



Joined: Jun 18, 2006
Posts: 151
Location: New York
Audio files: 1

PostPosted: Sun Nov 05, 2006 12:08 pm    Post subject: problems with sync Reply with quote  Mark this post and the followings unread

if sync 0 is frequency modulation, and vibrato is slow frequency modulation, why doesn't something like the following work in chuck?

Code:
SinOsc s => dac;
SinOsc lfo => s;
0 => s.sync;
440.0 => s.freq;
1.0 => lfo.freq;
10.0 => lfo.gain;
while(true) {
   10::ms => now;
}



but something like the following works:

Code:
SinOsc s => dac;
SinOsc lfo => blackhole;
440.0 => s.freq;
1.0 => lfo.freq;
while(true) {
   440 + (lfo.last() * 10) => s.freq;
   10::ms => now;
}


Also, modulating the phase works fine,

Code:
SinOsc s => dac;
SinOsc lfo => s;
2 => s.sync;
440.0 => s.freq;
1.0 => lfo.freq;
10.0 => lfo.gain;
while(true) {
   10::ms => now;
}




leading me to believe that the frequency sync just does not work like i expect it to. Am I missing something in the concept of a frequency sync or is something wrong with sync function? It seems like only the phase sync actually works. (This is 1.2.7b btw)

Also, notice that phase shift is not a workaround, as the blackhole version (frequency mod vibrato) sounds better, cleaner and less 'phasy' than the phase sync.

_________________
All phenomena are atoms in association and dissociation.
Back to top
View user's profile Send private message
kijjaz



Joined: Sep 20, 2004
Posts: 765
Location: bangkok, thailand
Audio files: 4

PostPosted: Sun Nov 05, 2006 2:48 pm    Post subject: Reply with quote  Mark this post and the followings unread

i thought sync == 1 is for phase mod and
sync == 2 is for simple FM...

is this what you're looking for?
- - -

i mainly use phasemod and FM.
and they still work fine for me.

phase mod..
i guess it turned out to be a waveshaper.

Code:
SinOsc smod => SinOsc s => dac;
1 => s.sync;
for(int i; i < 40000; i++) {
   i / 10000.0 => smod.gain;
   2 :: samp => now;
}


FM..
it's just simple FM.
Code:
SinOsc smod => SinOsc s => dac;
2 => s.sync;
for(int i; i < 40000; i++) {
   i / 4.0 => smod.gain;
   2 :: samp => now;
}
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
majutsu



Joined: Jun 18, 2006
Posts: 151
Location: New York
Audio files: 1

PostPosted: Sun Nov 05, 2006 6:55 pm    Post subject: Reply with quote  Mark this post and the followings unread

according to the manual, 0=FM, 1 is reserved, 2 = PM

Phase mod works, and is equivalent to FM synthesis in sounds.

But a true slow FM, a vibrato, does not work with sync 0 as it should.

Slow phase mod does not sound like vibrato.

something is wrong with sync.

_________________
All phenomena are atoms in association and dissociation.
Back to top
View user's profile Send private message
ian-s



Joined: Apr 01, 2004
Posts: 2664
Location: Auckland, New Zealand
Audio files: 42
G2 patch files: 626

PostPosted: Sun Nov 05, 2006 8:28 pm    Post subject: Reply with quote  Mark this post and the followings unread

Using the term sync to refer to PM or FM has me scratching my head.
Back to top
View user's profile Send private message
majutsu



Joined: Jun 18, 2006
Posts: 151
Location: New York
Audio files: 1

PostPosted: Sun Nov 05, 2006 8:41 pm    Post subject: Reply with quote  Mark this post and the followings unread

sync 0 means input Modulates Frequency, hence FM

syn 2 means input Modulates Phase, hence PM

but the thing is this doesn't work right

I really need to route the output to an oscilloscope . . . hey i think i'll try to do this

_________________
All phenomena are atoms in association and dissociation.
Back to top
View user's profile Send private message
kijjaz



Joined: Sep 20, 2004
Posts: 765
Location: bangkok, thailand
Audio files: 4

PostPosted: Mon Nov 06, 2006 3:18 am    Post subject: Reply with quote  Mark this post and the followings unread

according to
http://chuck.cs.princeton.edu/release/VERSIONS

new update for version: 1.2.0.7
Code:

  - (fixed) SinOsc/TriOsc/PulseOsc/SqrOsc/Phasor.sync now unified:
            .sync == 0 : sync frequency to input
            .sync == 1 : sync phase to input
            .sync == 2 : fm synth


so i guess you haven't checked out the page.
i was confused at first coz i read from the manual that came with chuck,
but the manual hasn't beed updated.

so i suggest you stick to the above page ^_^.

i've tested three of them.
they works fine.
so now you need sync == 1 for phasemod and sync == 2 for FM.
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
majutsu



Joined: Jun 18, 2006
Posts: 151
Location: New York
Audio files: 1

PostPosted: Mon Nov 06, 2006 6:43 am    Post subject: Reply with quote  Mark this post and the followings unread

very interesting!

it certainly explains the buzzy sound of sync 2 !

but how is fm (sync 0) different than fm synth (sync 2)?

also sync 0 when modulated slowly doesn't produce vibrato as true input modulating frequency would.

so, something is still wrong with sync. i know they are still working on this, as your problems with sync were what motivated 1.2.7b I believe.

thanks for showing the page.

i could of course use blackhole, but i don't like it when features don't work for me.

_________________
All phenomena are atoms in association and dissociation.
Back to top
View user's profile Send private message
kijjaz



Joined: Sep 20, 2004
Posts: 765
Location: bangkok, thailand
Audio files: 4

PostPosted: Mon Nov 06, 2006 1:31 pm    Post subject: Reply with quote  Mark this post and the followings unread

majutsu:

as i understand.. sync 0 is the same as setting freq of an oscillator.
but it uses the feeded signal as the freq.
so that..

Code:
// Step to SinOsc (sync the input signal to Frequency) to DAC
Step s1 => SinOsc s2 => dac;

// set sync type to Frequency (notice: not Frequency Modulation)
0 => s2.sync;
// feed signal with value 100, 200, 300, ... into s2, 1 second each.
for(1 => int i; i < 11; i++) {
   i * 100 => s1.next;
   second => now;
}

.. is the same as ..
Code:
// simple SinOsc to DAC
SinOsc s2 => dac;

// set s2\s frequency to value 100, 200, 300, ...
for(1 => int i; i < 11; i++) {
   i * 100 => s2.freq;
   second => now;
}

- - -

but FM (Sync number 2) is like adding the input value to freq.
so let's try this frist.. (using Sync number 0 to make a simple FM synth):

Code:
// use Step to set carrier signal's center frequency
Step sfreq => SinOsc s => dac;
// add modulation to s's frequency
SinOsc smod => s;
// the sum of sfreq and smod's output is gonna be s's frequency
0 => s.sync;

// set modulator frequency
300 => smod.freq;

// set carrier frequency
100 => sfreq.next;

// increase FM depth from 300 to 600 to 900 to ..., 1 second each
for(1 => int i; i < 11; i++) {
   i * 300 => smod.gain;
   second => now;
}

but we can shorten the code by using sync number 2 to make simple FM:
Code:
// use smod to modulate the frequency of s
// but we can set s's center frequency now.
SinOsc smod => SinOsc s => dac;
2 => s.sync;

// set modulator frequency
300 => smod.freq;

// set carrier frequency
100 => s.freq;

// increase FM depth from 300 to 600 to 900 to ..., 1 second each
for(1 => int i; i < 11; i++) {
   i * 300 => smod.gain;
   second => now;
}


those two codes above should sound the same.
using sync number 2 is more convenient in this way.

i love using sync 2 FM for this too
hehehe just for fun for now...
it's a self-Frequency-Modulating sine oscillator..


Code:
// SinOsc to DAC
SinOsc s => dac;
// Use s to self-modulate itself with FM sync
s => Gain FMdepth => s;
2 => s.sync;
4000 => s.freq;

for(0 => int i; i < 40000; i++) {
   i => FMdepth.gain;
   10::samp => now;
}

- - -

bye for now. i guess sync'd be clear for you now, majutsu ^_^
nice sharing with you.
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
majutsu



Joined: Jun 18, 2006
Posts: 151
Location: New York
Audio files: 1

PostPosted: Mon Nov 06, 2006 3:01 pm    Post subject: Reply with quote  Mark this post and the followings unread

well kijjaz, everything you say makes perfect sense in terms of my results, the scope results, etc.

i wish i would get some confirmation somewhere. The chuck list was unresponsive on this, and a previous thread on this was ignored. i am glad someone care about details and not just loosely slopping truth around Laughing

But your last post is dead on in terms of the playing i've done with the sync function. that's why, for example, an lfo of 10 hz at sync 0 makes no sound, because it's setting the frequecy to 10 - i.e. not audible. the manual, the language documentation, and the examples folder are all to the contrary on this. also, the english word sync should imply synchronization, not resetting, but programmers aren't notorious for human language communication skills Very Happy

not only that, but it appears we've lost the very important function of phase sync according to your explanation?!? so the endless rising tone accomplished by phase shifting a bank of oscillators would be impossible in chuck in 1.2.7b.

again, your hypothesis is clear and fits all my available data. so i thank you there -- and i think you are right.

this really needs to be clarified though. the manual needs redone, and the examples folder, and probably something needs to be on the wiki too. the way things stand, people attempting synthesis are sure to feel chuck is unreliable as documented. also, the term "fm synth" for sync 2 is very unclear at this point. sin (wA + p) modifying w is fm mod, p is phase mod. both will sound the same for simple lfo, but if it's really phase mod, and you put the sound through a delay line (which i can tell you know is like multiplying by a complex number . . . ) you will have unforseen chaos, not of the pretty kind. . . .

very helpful interchange. i can tell you've looked at chuck closely, and i thank you. Very helpful points indeed

brian

_________________
All phenomena are atoms in association and dissociation.
Back to top
View user's profile Send private message
ge



Joined: Aug 13, 2006
Posts: 105
Location: Palo Alto, CA

PostPosted: Mon Nov 06, 2006 11:43 pm    Post subject: Reply with quote  Mark this post and the followings unread

Hey all!

Sorry for the delay in a clear response and thanks to those who have investigated and tested this. We are currently in New Orleans for a conference (ICMC) and will devote time to this issue after we get back. This aspect is indeed poorly documented and also needs additional work in terms of implementation!

We shall refer back to this thread when we take another pass at .sync functionality. Sorry again for the delay in responding.

Best,
Ge!
Back to top
View user's profile Send private message Visit poster's website
kijjaz



Joined: Sep 20, 2004
Posts: 765
Location: bangkok, thailand
Audio files: 4

PostPosted: Tue Nov 07, 2006 1:19 am    Post subject: Reply with quote  Mark this post and the followings unread

thanks again majutsu & also ge.

to test them all, i'd like to try simple vibrato & using phasemod also..
maybe this topic can grow into a place with more reference on using oscillator sync option hehe.

with vibrato, i usually use FM.
(for me sync 2 == FM isn't too confused..
coz we're Modulating the Frequency of the oscillator..
so the input signal is going to modulate the value of the center frequency set in .freq)


Code:
// Main Oscillator: Sine Wave Oscillator to DAC
SinOsc s => dac;
220 => s.freq;

// LFO: use a triangle wave osc to FM the main osc
TriOsc lfo => s;
2 => s.sync;
// LFO frequency = 4hz
4 => lfo.freq;

// change modulation depth to see if it has the vibrato we need..
for(0 => int i; i < 10; i++) {
   i * 2 => lfo.gain;
   second => now;
}


now, i'm going to test the feature of PhaseMod
(i still haven't tested it with this simple way..
coz mainly i used it with other purposes.. and didn't test the simplest feature -_-"

i'm going to use p - a phasor.. to set the phase of s - the main sine wave oscillator
so now the .freq of s would not work. the value of s will be generated only from the phase sync.


Code:
// Main Oscillator: Sine Wave Oscillator to DAC
SinOsc s => dac;
// Phasor: use a phasor to set phase of the main osc
Phasor p => s;
1 => s.sync;

// run the main osc at different frequency by changing the phasor's frequency
for(0 => int i; i < 10; i++) {
   i * 100 => p.freq;
   second => now;
}


now i'm gonna try applying another signal to phasemod with the main osc.
doing this simply create FM sound..
is this way the poppular way in Digital FM Synth?


Code:
// Main Oscillator: Sine Wave Oscillator to DAC
SinOsc s => dac;
// !! setting the frequency will have no meaning now. -_-"
10000 => s.freq;

// Phasor: use a phasor to set phase of the main osc
// set the main phasor frequency to 220hz
Phasor p => s;
1 => s.sync;
220 => p.freq;

// use another oscillator to modulate the phase of the main osc..
// this should create an FM-Sound with phase mod.
// try phase-modding with sine wave at 660hz
SinOsc smod => s;
660 => smod.freq;

// change the gain of smod, and we've got a phasemod FM synth sound ^_^
for(0 => int i; i < 10; i++) {
   i * 0.2 => smod.gain;
   second => now;
}


what i've been using with PhaseMod is for waveshaping effect.
i feed the input signal into an oscillator..
for example, a sine wave oscillator.. with PhaseMod sync ..
this will perform waveshaping distortion with the input signal.
(if input signal is x,
the output signal would be sin(2 * pi * x) )
so we've got sin(2 * pi * x) as the waveshaping transfer function.)

with this, no matter how much signal we feed in,
the output would always be between -1 and 1.
when increasing the gain of the input,
we'll get one nice analog-sounding distortion.


Code:
// Main Oscillator: Sine Wave
SinOsc s;

// Connect main osc to Waveshaper (with Sine transfer function), and to DAC
s => SinOsc waveshaper => dac;
1 => waveshaper.sync;

// let's try a synth sound with falling frequency.
// and also a falling gain.
// i'll make the gain fall faster by pow10
// it's an attempt to create an analog bassdrum sound
// with a slight overdrive.
// change the 1.2 value to a higher / lower value to hear the different overdrive amount.
// at 0.5 and above, it'll start to clip and create a warm overdrive.
for(1 => int i; i < 10; i++) {
   for(0 => int j; j < 1000; j++) {
      i * 20 * (1000 - j) * 0.001 => s.freq;
      Math.pow((1000 - j) * 0.001, 10) * 1.2 => s.gain;
      ms => now;
   }   
}


- - -

enough for today..
i'm going to have breakfast heheh ^_^
i'll share with you all more on the way i use sync.
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
kijjaz



Joined: Sep 20, 2004
Posts: 765
Location: bangkok, thailand
Audio files: 4

PostPosted: Tue Nov 07, 2006 2:34 am    Post subject: Reply with quote  Mark this post and the followings unread

ahh.. done from breakfast ..

(breakfast at 3PM? -_-")

ge, i've been thinking about sync
and have some suggestions.

- now, using phasemod (sync == 1) make .freq disabled.
but i think it'd be more useful if it's enabled.

so we'll have the oscillator running at the specified .freq
but the index (for table look-up) can be modified with phasemod.
with this, it's like setting the offset of the index.. (am i right?)

- now, frequency sync (sync == 0) is just the same as FM with freq == 0
so i think sync == 0 is still not that important..
...

hmm i dunno.. but it still makes sense to me to have a frequency sync.
so it's up to the next version(s)


i've got no other ideas for now.
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic Moderators: Kassen
Page 1 of 1 [12 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


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003 through 2009 by electro-music.com - Conditions Of Use