Continuous sound from 1sec. sample

Programming applications for making music on Linux.

Moderators: MattKingUSA, khz

SeeLook
Established Member
Posts: 28
Joined: Thu Feb 21, 2013 8:09 pm

Continuous sound from 1sec. sample

Postby SeeLook » Tue Aug 29, 2017 6:48 pm

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?

fundamental
Established Member
Posts: 150
Joined: Thu Nov 07, 2013 1:19 pm

Re: Continuous sound from 1sec. sample

Postby fundamental » Tue Aug 29, 2017 11:19 pm

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)
ZynAddSubFX maintainer

SeeLook
Established Member
Posts: 28
Joined: Thu Feb 21, 2013 8:09 pm

Re: Continuous sound from 1sec. sample

Postby SeeLook » Wed Aug 30, 2017 6:25 pm

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.

User avatar
Michael Willis
Established Member
Posts: 541
Joined: Mon Oct 03, 2016 3:27 pm

Re: Continuous sound from 1sec. sample

Postby Michael Willis » Thu Aug 31, 2017 1:51 am

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.

User avatar
raboof
Established Member
Posts: 1529
Joined: Tue Apr 08, 2008 11:58 am
Location: Deventer, NL
Contact:

Re: Continuous sound from 1sec. sample

Postby raboof » Thu Aug 31, 2017 8:19 am

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'.

SeeLook
Established Member
Posts: 28
Joined: Thu Feb 21, 2013 8:09 pm

Re: Continuous sound from 1sec. sample

Postby SeeLook » Thu Aug 31, 2017 5:09 pm

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.

ssj71
Established Member
Posts: 1262
Joined: Tue Sep 25, 2012 6:36 pm

Re: Continuous sound from 1sec. sample

Postby ssj71 » Thu Aug 31, 2017 10:24 pm

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.
_ssj71

music: https://soundcloud.com/ssj71
My plugins are Infamous! http://ssj71.github.io/infamousPlugins
I just want to get back to making music!


Return to “Developer's Section”

Who is online

Users browsing this forum: No registered users and 1 guest