[.uhm] FM Synthesis in Hive
- u-he
- Topic Starter
- 28043 posts since 8 Aug, 2002 from Berlin
I guess this should do the trick:
Spectrum "x * ( index % 2 )" [edit: fixed...]
Odd harmonics are 1 (fundamental), 3, 5, ... -> "index % 2" should be 1 for 1, 3, 5... and 0 for 2, 4, 6..., hence all odd harmonics are left untouched while all even harmonics are set to 0.
Spectrum "x * ( index % 2 )" [edit: fixed...]
Odd harmonics are 1 (fundamental), 3, 5, ... -> "index % 2" should be 1 for 1, 3, 5... and 0 for 2, 4, 6..., hence all odd harmonics are left untouched while all even harmonics are set to 0.
-
- KVRist
- 138 posts since 5 Oct, 2015
-
- KVRist
- 138 posts since 5 Oct, 2015
Sorry, that was part of the full code.. the idea was to morph from any kind of wave to a "squarified" one, and the table was part of this. Something like:
(x)*(table-1)+(squarified(x))*table
increasing the "squarified" part of the wave over time. Does not sound spectacular so far, needs more work...
(x)*(table-1)+(squarified(x))*table
increasing the "squarified" part of the wave over time. Does not sound spectacular so far, needs more work...
- KVRAF
- 4119 posts since 23 May, 2004 from Bad Vilbel, Germany
I'd be interested in a function that creates "bells" consisting of equally-spaced harmonics (e.g. 1, 4, 7, 10... or 3, 8, 13, 18...). Of course you could add or subtract multiple waves for more complex bells. Any takers?
-
- KVRist
- 138 posts since 5 Oct, 2015
The modulo division should give you that: (x % 3) == 1 delivers 1, 3, 4, 7... How about:
(1/index)*((index % 3)==1)
in a Spectrum line? (Sorry can't check right now)
-
- KVRist
- 138 posts since 5 Oct, 2015
I have no idea what is happening here, but with spectral morph it looks awesome:
>>
Info "Happy Accident - Generating Bells (?)"
NumFrames = 2
Spectrum "(1/index)*((index % 3)==1)+(1/index)*table"
Spectrum "(1/index)*((index % 3)==2)"
Spectrum lowest=0 highest=0 "0" // DC-removal trick
Normalize start=0 end=2
>>
The idea was to generate some bells, but something went wrong... can somebody explain what I did here?
>>
Info "Happy Accident - Generating Bells (?)"
NumFrames = 2
Spectrum "(1/index)*((index % 3)==1)+(1/index)*table"
Spectrum "(1/index)*((index % 3)==2)"
Spectrum lowest=0 highest=0 "0" // DC-removal trick
Normalize start=0 end=2
>>
The idea was to generate some bells, but something went wrong... can somebody explain what I did here?
- KVRian
- 544 posts since 1 Jan, 2013 from Saint-Petersburg, Russia
InterestingZaBong69 wrote: ↑Tue Feb 19, 2019 2:44 pm I have no idea what is happening here, but with spectral morph it looks awesome:
>>
Info "Happy Accident - Generating Bells (?)"
NumFrames = 2
Spectrum "(1/index)*((index % 3)==1)+(1/index)*table"
Spectrum "(1/index)*((index % 3)==2)"
Spectrum lowest=0 highest=0 "0" // DC-removal trick
Normalize start=0 end=2
>>
The idea was to generate some bells, but something went wrong... can somebody explain what I did here?
First off, each (1/index) part should've give you an error, because index goes from 0 to 2047, so the very first iteration would be a division by zero. Which is a no-no. But I guess UHM is forgiving for that kind of error and just returns 0.
Your first line Spectrum "(1/index)*((index % 3)==1)+(1/index)*table" uses a table variable. You have 2 frames in total. By introducing a table variable you get different results for each frame, because for frame #0 the table will be 0.0, and for frame #1 it will be 1.0.
In your second line Spectrum "(1/index)*((index % 3)==2)" you don't use table variable, therefore both frames should be equal, and since you didn't specify a Blend mode, that line should overwrite the result of the previous line, because default Blend mode for Spectrum command is Replace. But that's not what we see So I'd guess you found a bug. Or it's a known quirk. Or I missed something
- u-he
- Topic Starter
- 28043 posts since 8 Aug, 2002 from Berlin
In Spectrum, "Lowest" defaults to 1, for the very reason that 1/index would give us an unforgivable error.
- KVRian
- 544 posts since 1 Jan, 2013 from Saint-Petersburg, Russia
- u-he
- Topic Starter
- 28043 posts since 8 Aug, 2002 from Berlin
I think I can explain it.
The spectrum is identical in both frames, but the first frame has mangled random phases for each harmonic.
The first line sets the first table to 0.0 all over, because >> *table <<, as drzhnn pointed out. That is, because everything is 0, there is no defined phase for any harmonic in the first frame, but it's all good and tidy in the second frame.
The second pass >> Spectrum "(1/index)*((index % 3)==2)" << overwrites the magnitudes of each harmonic again. The phases of the first frame are pretty much random, while the second frame looks like it does.
The spectrum is identical in both frames, but the first frame has mangled random phases for each harmonic.
The first line sets the first table to 0.0 all over, because >> *table <<, as drzhnn pointed out. That is, because everything is 0, there is no defined phase for any harmonic in the first frame, but it's all good and tidy in the second frame.
The second pass >> Spectrum "(1/index)*((index % 3)==2)" << overwrites the magnitudes of each harmonic again. The phases of the first frame are pretty much random, while the second frame looks like it does.
- u-he
- Topic Starter
- 28043 posts since 8 Aug, 2002 from Berlin
- KVRian
- 544 posts since 1 Jan, 2013 from Saint-Petersburg, Russia
Maybe this?
Code: Select all
NumFrames = 1
Spectrum lowest=2 highest=20 "(index % 5) * (1/index)"
// ___________________ _________ _________
// | | |
// Working only with Selecting This adjusts the magnitude of the target harmonic.
// harmonics 2-20 each 5th By default, if "(index % 5)" is true, it is set to 1.0.
// harmonic, To get a more natural sound, especially if we have
// and giving a lot of harmonics, it's useful to reduce the magnitude
// it a value of higher ones. So the higher the harmonic, the
// of 1.0 more quiet it gets. Therefore we divide 1 by the index of
// (default) the harmonic.
Spectrum lowest=1 highest=1 "1" // Adding fundamental
Code: Select all
NumFrames = 1
Seed = 1234
// |
// Change me, completely!
Spectrum lowest=2 highest=200 "(index % (rand * 7)) * rand"
// ___________ ___ _____
// | | |
// If set too high, it can | Random magnitude
// add a lot of ultra high |
// frequencies, ecpecially Harmonic
// when working in higher gap
// samplerates like 96k.
Normalize base=all db=-12 // Reducing loudness of all overtones
Spectrum lowest=1 highest=1 "1" // Adding fundamental
-
- KVRist
- 138 posts since 5 Oct, 2015
>>
The first line sets the first table to 0.0 all over, because >> *table <<, as drzhnn pointed out. That is, because everything is 0, there is no defined phase for any harmonic in the first frame, but it's all good and tidy in the second frame.
>>
Not unless UHM ignores the rules of algebra. That only sets the second term to 0, not the first one as I add these, and *table should only work on the first or should it?
Anyway, the resulting curve looks a lot like a random walk, which is pure magic as it was not intended at all. I suspect that a lot of these happy accidents are prone to happen when people like me - not really knowing what they are doing - are using this technology in earnest.
Urs, you are basically handing a bunch of 4-year olds the synth equivalent of a box of handgranades to play with. I am very grateful for this
The first line sets the first table to 0.0 all over, because >> *table <<, as drzhnn pointed out. That is, because everything is 0, there is no defined phase for any harmonic in the first frame, but it's all good and tidy in the second frame.
>>
Not unless UHM ignores the rules of algebra. That only sets the second term to 0, not the first one as I add these, and *table should only work on the first or should it?
Anyway, the resulting curve looks a lot like a random walk, which is pure magic as it was not intended at all. I suspect that a lot of these happy accidents are prone to happen when people like me - not really knowing what they are doing - are using this technology in earnest.
Urs, you are basically handing a bunch of 4-year olds the synth equivalent of a box of handgranades to play with. I am very grateful for this