Hi,
Is it possible to having a samples of a tone of 1 second long, pragmatically (c++) assemble any duration of this tone?
I mean, i.e. how to loop that audio data:
I already tried to combine and cross-fade last samples with samples at start (10-100ms) but all my attempts have kind of crack during transition.
The question is not about code exactly, but more about approach. How midi sound is produced from some audio data?
Continuous sound from 1sec. sample
Moderators: MattKingUSA, khz
-
- Established Member
- Posts: 165
- Joined: Thu Nov 07, 2013 1:19 pm
- Been thanked: 1 time
Re: Continuous sound from 1sec. sample
What type of sound? (drum/guitar/horn/wildlife/etc)
Have you tried matching zero crossings for when your fading out/fading in?
How are you fading? (linear/log-equal-volume)
Is the goal a droning sound? (you could use fft->phase-randomization->ifft if that's the case)
Have you tried matching zero crossings for when your fading out/fading in?
How are you fading? (linear/log-equal-volume)
Is the goal a droning sound? (you could use fft->phase-randomization->ifft if that's the case)
ZynAddSubFX maintainer
Re: Continuous sound from 1sec. sample
Thanks for the answer.
The sound is a single note of instrument with continuous (not fading out) sound: sax, accordion, violin, etc.
I'm fading in/out by increasing/decreasing amplitude of beginning/end of sound, I'm multiplexing every sample by increasing/decreasing factor during in 5ms span time.
My goal is to having samples of each note achieved by instrument with limited duration (1.5) produce any longer and robust sound of that note.
I'm doing that realtime in callback.
The sound is a single note of instrument with continuous (not fading out) sound: sax, accordion, violin, etc.
I'm fading in/out by increasing/decreasing amplitude of beginning/end of sound, I'm multiplexing every sample by increasing/decreasing factor during in 5ms span time.
My goal is to having samples of each note achieved by instrument with limited duration (1.5) produce any longer and robust sound of that note.
I'm doing that realtime in callback.
- Michael Willis
- Established Member
- Posts: 1458
- Joined: Mon Oct 03, 2016 3:27 pm
- Location: Rocky Mountains, North America
- Has thanked: 70 times
- Been thanked: 166 times
- Contact:
Re: Continuous sound from 1sec. sample
Doing it realtime is going to be tough. I haven't done anything of the sort myself, but I have read tales of woe from Paul Battersby when he was working on looping samples one by one for his excellent Virtual Playing Orchestra.
- raboof
- Established Member
- Posts: 1855
- Joined: Tue Apr 08, 2008 11:58 am
- Location: Deventer, NL
- Has thanked: 50 times
- Been thanked: 74 times
- Contact:
Re: Continuous sound from 1sec. sample
One trick I used in a distant past that may help is to 'pingpong' through the sample instead of 'looping' it. Still probably needs some fading and you'll likely still hear the length of the loop, but it should reduce the 'crack'.
Re: Continuous sound from 1sec. sample
Thanks a lot for clues,
You convinced me to try following:
- find start point at zero-cross before highest peak of note period at about 200ms of a sound (to skip initial part)
- find end point also at zero-cross but at the sound end (90% of duration)
- a) loop between those points
- b) pingpong??? Is that mean to revert directions when end point is achieved?
I can prepare those points when samples are loaded to memory, to have them ready in callback,
and fading in callback by multiplying samples during they are copied to output buffer is light thing. Either JACK in low latency (64 frames) bears it or low end, old mobile device. I had never problem with that.
I believe I can have samples with equal dynamic, but a vibrato of a violin could be a challenge.
I will try and give You feedback.
You convinced me to try following:
- find start point at zero-cross before highest peak of note period at about 200ms of a sound (to skip initial part)
- find end point also at zero-cross but at the sound end (90% of duration)
- a) loop between those points
- b) pingpong??? Is that mean to revert directions when end point is achieved?
I can prepare those points when samples are loaded to memory, to have them ready in callback,
and fading in callback by multiplying samples during they are copied to output buffer is light thing. Either JACK in low latency (64 frames) bears it or low end, old mobile device. I had never problem with that.
I believe I can have samples with equal dynamic, but a vibrato of a violin could be a challenge.
I will try and give You feedback.
Re: Continuous sound from 1sec. sample
I've played a lot with this for my infamous stuck plugin. You can view the source at https://github.com/ssj71/infamousPlugin ... ck/stuck.c
I used an autocorrelation method to try to identify a period in the ballpark of 2 and 15 ms. I then layer 2 periods of time with a crossfade. I tried some compression but it didn't seem to imrpove things very much. I was set on keeping in the time domain, but for polyphonic sounds (such as a guitar chord) it still has some beating/loop artifacts. I tried more layers, various crossfacdes etc, but I think you can;t get much better without using some time domain techniques. If I were to do it over again, I'd use a phase vocoder. I've looked a bit at the paulstretch algorithm which works very well for "freezing" audio, I actually planned to try taking just that module and making a stuck 2.
Another lv2 plugin example which does use a phase vocoder IIRC is the https://github.com/romi1502/MrFreeze
I actually haven't tried it yet, it was written for the MOD ecosystem (but should be easily portable). Unfortunately I've heard it still has some artifacts. To be sure this is a difficult problem in the audio world. Not unsolveable though, just needs polish.
I used an autocorrelation method to try to identify a period in the ballpark of 2 and 15 ms. I then layer 2 periods of time with a crossfade. I tried some compression but it didn't seem to imrpove things very much. I was set on keeping in the time domain, but for polyphonic sounds (such as a guitar chord) it still has some beating/loop artifacts. I tried more layers, various crossfacdes etc, but I think you can;t get much better without using some time domain techniques. If I were to do it over again, I'd use a phase vocoder. I've looked a bit at the paulstretch algorithm which works very well for "freezing" audio, I actually planned to try taking just that module and making a stuck 2.
Another lv2 plugin example which does use a phase vocoder IIRC is the https://github.com/romi1502/MrFreeze
I actually haven't tried it yet, it was written for the MOD ecosystem (but should be easily portable). Unfortunately I've heard it still has some artifacts. To be sure this is a difficult problem in the audio world. Not unsolveable though, just needs polish.
_ssj71
music: https://soundcloud.com/ssj71
My plugins are Infamous! http://ssj71.github.io/infamousPlugins
I just want to get back to making music!
music: https://soundcloud.com/ssj71
My plugins are Infamous! http://ssj71.github.io/infamousPlugins
I just want to get back to making music!