Created
November 15, 2019 21:41
-
-
Save Xenakios/45af4f49f2bde5b0afbfda51b8bf2330 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void test_soul() | |
| { | |
| SF_INFO outinfo; | |
| memset(&outinfo,0,sizeof(SF_INFO)); | |
| int outlen = 4*44100; | |
| ClassicRingtone tone; | |
| std::cout << "soul dsp num outputs : " << tone.getOutputEndpoints().size() << "\n"; | |
| outinfo.channels = tone.getOutputEndpoints().size(); | |
| outinfo.format = SF_FORMAT_FLOAT|SF_FORMAT_WAV; | |
| outinfo.samplerate = 44100; | |
| std::vector<float> outbuf(outlen*outinfo.channels); | |
| SNDFILE* outfile = sf_open("C:\\MusicAudio\\soultests\\soul_out1.wav",SFM_WRITE,&outinfo); | |
| if (outfile) | |
| { | |
| ClassicRingtone::RenderContext ctx; | |
| ctx.inputChannels = 0; | |
| ctx.numFrames = outlen; | |
| float* outchans[8]; | |
| for (int i=0;i<outinfo.channels;++i) | |
| outchans[i] = &outbuf[i*outlen]; | |
| ctx.outputChannels = outchans; | |
| ctx.numOutputChannels = outinfo.channels; | |
| tone.sampleRate = outinfo.samplerate; | |
| tone.render(ctx); | |
| sf_writef_float(outfile,outbuf.data(),outlen); | |
| sf_close(outfile); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment