Record audio of unknown length
-
Hey, smarter people! I'm trying to script something that's sadly a bit out of my skill set. Here's a snippet with just a momentary button and a noise generator:
HiseSnippet 1490.3oc6W0saaaCElx1JswscasnWrKEJ1EtCEtVNosqXXnNwItyX0oF1YA8pUvHQaSXJRMIpl3VTfdwtXO.69c2dN1qxdC5av1ghRVRwt4GuzhcwRAJLOGdH+3gemOdT+.gCILTDfLpt+LeBx35lCmwkSZOAS4nt6fL9Lyd3PIIvRaZ6Y93vPhKxvn7SUFLVuBJ9u2+jswLL2gjYBgNPPcHOi5QkYV625GnLVGrKYepWtYuYqtNBdaASDA3orYCjO1YJdLYOrZZkLQeONbBx3qM2nIdiMd7iZzz1dziZ9fQ11Md3F1ivaZCdZhIMebSrMQgj010kJEACkXIIDYTYag6rgSDGw0avAzP5gLhZfMZHryZycDLW0QT8aT6ITla+zDUHBYX1OKsUVm1tsYOpKct8rz2WD6vJKh7IPiREgW4Bvy9CAuk.IibPphFR2zbnS.0Wl4QgmqY1kC2livP1IOTzyEU52LLaKfYvk08vSIcBfAyin1Caz3dVv+c2usZU3tJTZ8Jbf0.hiHv056rRibLQ1V34K3vfZ2Q69NpXpR4LJmXMJh6HoBtkfq8phLPvp4jF18fUlEQta02Tc86e+sbcslAzBKmnPovyhIFScrlPBH0qWu5agU9z255gJywaQaLicHvqpchsFfWNTsmPRdNuV71W8sUsNoqQiVpuj0hQBVpaEeO3zBrFOx6PRP9CuZhvcZQhxZmOhhiNojahBdWNU9beRx3Llt8RnUnjrphfkfPXpxX50mkPu1NRJEbDEVjqZpynnXzC0IFw00+X2cvRb5Z.KGrE9j.IUcRL1g7JPhPSYW2bGR3TovOdtI2hHiqb163wykQdGt0rLMkep0QTW4j4F9yfVSHzwSj4sPC6I7fcBG.QZTBsXsDTEKbiXXYwRak.XhC3ZrP8jplgGRkyxKPdx58Je3qwFKUNZoWRmS3dSy9Toyjki2RKAuvM1Ga7lnddCycGMh3Hy.aEyNu3TkJqb9p.NCk77xllZrTMgkA6uBHWOYnUmWXW.P6E4sUjKUzgxT3wzPQ1STQM9Uyrha+.hONfrunOCOqVH1ymQF.Gh6YcHS3LcH80jEUD703Za0Lp4LAy4DV3pHbr1kzKLnAhHIkOtGVFPgpMS37ODTjcHsSPmJGTRoYnG2Hs9eHg6FO3ug+RbZOOgANsSclI2f1iHORDLM9NJ42fNf5BopYPbIOI.sEiINRoSPSHzv0Rrs9B1L+IBN0QYROiTbtkmHRIpnAKzQw9XJSUALLJDjEceNeHL431XLJe.IHLdguhYi5v+fJh8Dtp9J5fcfz5r9Xk3xMMUJs.2kDT2YNGNGRKPbh6lImS0Jl10iNkAH1KV4C54wnbN4RMiUMBpSKo4mcCOP40AyPGn0cgSlZM0IOMbUS8FlifS1K8AZHrqEN.2BN.vao48uHjKF+EA0JW.q+3z2AxU3jeDTU2k6RNNcA2EnztP4abXIbjdT9A4ecoG93BiQ8wA.ZgFVTqck4ifqvrPyT3xBetsVCkDeUUYdk6gSIGoyX4sp6OVUWq5nnmJUuvNrCYDNhIWvN5hCM.FWHnsF7.kbAH89mrbH89mbFPZyVK.oV+9RxVPU8GDRet4.gP1If7yQPM1rSfs28lVKEafczkvMYq+50+xojttloBWCTRIqRNSwy2VHl5gi0sVo1dx+13U0Nuh4dBZHIVQ4V5ea8TBnzndc29x36w7O2eOlQ4U5Q3hsIka9K4E4Jer91pOo8Z8uu0vKmOEb8TLNjpDf2k+JBCHgIjoDNcp0hjodBtH8MzL9y.B77+3wjhEOK6.skTBZhYVtcqADFAGlQv9p+n0yfmLwAwBmezyEm180WZpgqkpBv5+ao++ZszeAfxmh9T+TrGdXm.wKczs2q3xWM1Bbt4wcistYO0XK6zu1N6N1CTEeoiSwkZg.atpAtwpF3lqZfOXUC7gqZfOZUC7aN6.UOZsUjT3oKYgVW5uqtEWic4XfwGWcf9G70lSWM
What I would like to achieve is to record the audio buffer when the record button is on, and then use that as an external audio file in scriptnode.
I was hoping I could do it with the recorder node, but unfortunately, it needs to know the length of the recording beforehand.
Any help would be greately appreciated! Thank you!
-
You might need a custom recorder implementation. I'm not sure if scriptnode has one for this. I can create one if it turns out there isn't
-
@griffinboy that would be amazing, thank you!
With a feature like this, one could create so many things, even a mini-DAW in HISE
-
@tomekslesicki The way I do it is from the
processBlock
callback of a scriptFX (note that you must not create a scriptnode graph, otherwise it overwrites the callback, so you need a script just for that purpose)HiseSnippet 1921.3oc6X80aaibDmz1LIR2eZyg6g93hfVT4jTcRI9bRf6cQ9uWM5YGAKWiCvv0XE4RoElZW1kKsstCF3dnOzuE8s94neU52f7MnclcIMIsTbr04KEEn1NAbmcFt+lYm42rK6pj9rjDoxws99iiYNterWuwB8v0GR4Bms2vw8S81glnYJhUzZiioIIr.GW24+FTfasEbL+71WuFMhJ7YEhbbNPx8YeKeDWWHsam+HOJZKZ.ae9nRZuTms8kh0kQxT.Oy60xIl5eBc.aWJp1bdN+AZxPG2G605KWlwdwyCCBnO+4AKu7xu5kuZoW0lF1ZIZ+1K+pkd1Ru3Yu7EgNt2ay.tVp5ooZVhi6BqICF2an7LgcANfmv6GwvAsc5AqrU7Vxn.zEQoNqOjGEzMOPk33350sHrMuMr84d6vC3WJuH78KMSPJrnb.zctpva9JvqcY30pD7lBjbKAoErP5gd87U7XcwLHd9HusEvtYHE1mJCEqtNy8aVvacIngP2bD8D1VJXvkVzX4VsdJA9uEWodcXuJQSNkpH6w7kp.xWQxsb.SutbTrT.CZ7H6zOBsYPjrOMhL3XUtIgznD1JESP88SGkFQgnBL6gGAFoXCHxTcbpdszvPlBDUuNWDwELRXpvWykBhTXWFDBJYTC+70+o.DiRYKV+GpWqz5ZDtR8Z0qwCIMxToFnSMS9eSZPvtRM6MhFsAOdI6+P+9pJDFlqQ6VsLQlZWTuFC7J6qCWQHPoR80PvbzpE9WCqtW.9y0G3ZlfhM905znn9PUQiq3uKZBJSDUttEGCHkCqPPw9PSeECxGaTYynYDSLPOj7XxlhAvZfP0pdO92yZr3hlXYHrq0nOgKptSlEYij9vdb+i4AmCKV0WOWDvN+MgM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mANfh0r77SB4p1eaPMNEj0eddAZoBmxiflDaimJN+EtIjRG.s2LlkkirCWj4kVc1gddkwNcoJ.svYmw28BWNB1BKLsnsag4WJqSOMKFqJKebhdmvNyFwJK094Bv5Z7JJ6fg5IVgMXgzzH8Dxct8PCfwsBZ2CN0jdBH81WOcH81W+dfzRcl.Rc96SIZAU0uSH8K71SJgqlw9KoPM13qfse7G5LUrAxctC1I67u99+50Dt9HODW6gTIyRLCyyWSJOYD0va8StezCrSdeuck7DlgQ4yrOS9Fl.uanT09t3ySEei+7TtyeiOj5s3qKsvOWecoOnm4+m9UTta9XX0xwXONx4to3TVDj2kk+jkFmKsZ9yNRgLusYQJydLniO9QCpTuLMGZUsFnAKj74c1iAWsOoHm5W+O57sPWRpxvUNawh125OL3T2u9UdV3Rvjdx++pk+W4pk2MP4CwQS+PrFin9J4w91Szi4xOvHA7ag4.X071AGSZO4m5YDvJdrue0W0DF9rY0vmOqFtzrZ3WNqFt7rZ3KlUCe462Pro0poZ4HaIKbZktaZOUq6lBJjwapNb9OKp.ZQ.
I am not proud to iterate over each sample to reconstruct the final buffer, but I haven't found a way to
referTo
when target buffer is bigger than reference...
Usually I do the opposite (I know the length of my recording in advance)
So if someone has an idea how to copy a smaller buffer anywhere in a bigger one!Now, there might also be a solution through scriptnode, but I have no idea and the "full script way" of the example isn't hard so...
EDIT: We need a
Buffer.copyFrom
method -
@ustk thanks, I almost understand the example ;-) Could you please help me out to get the output of the buffer into the file player in scriptnode?