Is there a way to batch change all the sample starts in an instrument to half?

ockpii
ockpii Member Posts: 9 Member
edited November 2022 in Scripting Workshop

Hi all. A few months ago I released an instrument called the woodland piano (https://www.pianobook.co.uk/packs/woodland-piano/), which was recorded at 96k. Unlike a second piano recorded in the exact same way, when played at 48k there is some nasty aliasing artifacts fixed only by playing the instrument in HQI as high.

A while back I batch downsampled it all to 48k but it sounded all warbled. Only now did the epiphany came that the sample start was now at double what it needed to be.

So, instead of manually changing the sample start of 1071 samples, is there a way to do this in some sort of automated process? The samples don't have shared sample starts.

Thanks very much!

Comments

  • Paule
    Paule Member Posts: 1,328 Expert

    Mayhaps polyphone can do this for you?


  • ockpii
    ockpii Member Posts: 9 Member

    Heya Paule, thanks for your comment. Not seeing how I'd use Polyphone for a mass change inside a Kontakt instrument. It looks like this would simply be recreating the instrument inside a different engine. Is there something I am missing?

    Thanks again!

  • Gablux
    Gablux Member Posts: 71 Member

    Sample starts don't have a direct correlation with sample rate conversions, at least not in this case.

    Are you sure you didn't mess up in the conversion phase? The samples should not sound warbled.


    However, if you only wanted to batch change the sample starts (not considering this context), you can use Creator Tools and Lua scripting to do that.

  • stephen24
    stephen24 Member Posts: 245 Advisor

    Totally baffled about what you're trying to do. Are you playing back samples recorded in 96k at 48k, i.e.an octave lower? if so the sound will certainly be weird and totally unaffected by the HQI setting (which deals with sounds transposed in the mapping editor.)

    Can't quite see how sample start is relevant for a piano instrument, but you can adjust it for any number of samples by highlighting them in the mapping editor (lasso them) and, in the wave editor, gear wheel/to all selected zones/copy current sample-start settings.

    (Yet another post inappropriately relocated to the Scripting Workshop. Let's hope the OP can find it.)

  • ockpii
    ockpii Member Posts: 9 Member
    edited November 2022

    Hi again. Thanks for your time. I'll re-frame the question in a more direct way.

    The original samples were recorded at 96k and I'd like to have a 48k version. As downsampling reduces the amount of samples in each sample, the previously correct sample start time is now way ahead of what it should be.

    This image shows the exact same sample, only the sample start had to be shifted to accommodate for the difference in sample rate, one start being 1/2 of the other.

    The question is, is there a way to automatically set every individual sample start of each sample to half of what it currently is, instead of manually shifting it sample by sample inside this instrument?

    Hopefully that cleared some questions up. Thanks again for taking the time.

  • medusa
    medusa Member Posts: 81 Helper

    You could use CT to halve the start time offset of all zones.

  • stephen24
    stephen24 Member Posts: 245 Advisor
    edited November 2022

    Sorry, I now see that your original post was quite clear

    Don't know anything about Creator Tools, but Goldwave will allow you to batch Trim Leading Silence. You can leave a timed bit of silence at the beginning if you want to. You could then set one zone's sample-start and use gearwheel/to all selected zones/copy current sample-start setting.

    Goldwave is a very fine audio editor, and I think they have an "evaluation version"

  • ockpii
    ockpii Member Posts: 9 Member
    edited November 2022

    Thanks for both your suggestions. Halving the sample starts would be ideal as they are all slightly different from sample to sample instead of bang on identical.

    I'll be looking at the documentation for Creator Tools to see if I can manage my way around it, but if you've got any tips or useful reading material I'd be very grateful.

    Thanks again, folks.

  • medusa
    medusa Member Posts: 81 Helper

    If it's ALL the sample zones in your instrument, it should be a very simple script. Something like this

    for n,g in pairs(instrument.groups) do
       for n,z in pairs(g.zones) do
           z.sampleStart = z.sampleStart / 2
       end
    end
    
  • ockpii
    ockpii Member Posts: 9 Member
    edited November 2022

    Hey, thanks so much. It is for all the sample zones in the instrument yes. I tried your code but it gave me this error:

    And no effect is taken by pushing it to Kontakt. Any idea on what is causing that?

    Thanks again!

  • medusa
    medusa Member Posts: 81 Helper

    I think that's because of the .5s from dividing odd numbers by 2.

    Try replacing the main line with this, to round them all down to integers.

    z.sampleStart = math.floor(z.sampleStart / 2)

  • ockpii
    ockpii Member Posts: 9 Member

    I believe that that worked flawlessly, thank you so much! I'll do some digging into the different groups to make sure it's all working properly but that seems to have done it!

Back To Top