HISE Logo Forum
    • Categories
    • Register
    • Login

    Bulk Convert SampleMaps to WaveTables

    Scheduled Pinned Locked Moved Feature Requests
    25 Posts 4 Posters 1.2k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ?
      A Former User
      last edited by

      After individually converting about 30 of them, could we pretty please possibly get an option to loop the conversion for all the SampleMaps in the folder using the same settings?

      I'd do it myself but there's a 90% chance I end up breaking both HISE and the OS of my computer :)

      Christoph HartC 1 Reply Last reply Reply Quote 0
      • Christoph HartC
        Christoph Hart @A Former User
        last edited by

        @iamlamprey But it's a 10% chance that you succeed so go for it! :)

        1 Reply Last reply Reply Quote 0
        • d.healeyD
          d.healey
          last edited by

          Make it command line accessible and then you can just write a script to do it :p

          Libre Wave - Freedom respecting instruments and effects
          My Patreon - HISE tutorials
          YouTube Channel - Public HISE tutorials

          1 Reply Last reply Reply Quote 0
          • ?
            A Former User
            last edited by

            Well I made the button show up... thinking about writing a book on advanced C++ 😂

            01365e62-1b65-460c-883c-500a23fcbbf0-image.png

            Okay so I know I need to add this:

            else if (name == "BulkConvert")
            		{
            			for (int i = 0; i < list.size; i++)
            			{
            				
            			}
            		}
            

            To the button function, and I assume I need to make sure list is visible to it, but I have no idea where to start with iterating through, since it relies on the currently loaded/selected samplemap of the combobox...

            This next part is from a different function so I assume I can't access the result of it

            void comboBoxChanged(ComboBox* comboBoxThatHasChanged) override
            	{
            		if (getComboBoxComponent("samplemap") == comboBoxThatHasChanged)
            		{
            			auto& spool = chain->getMainController()->getActiveFileHandler()->pool->getSampleMapPool();
            
            			PoolReference ref(chain->getMainController(), comboBoxThatHasChanged->getText(), FileHandlerBase::SampleMaps);
            
            			currentlyLoadedMap = ref.getFile().getFileNameWithoutExtension();
            

            @d-healey Is this a thing on windows? I'd rather tinker with C++ but it could be an option if I cant figure it out

            d.healeyD 1 Reply Last reply Reply Quote 0
            • d.healeyD
              d.healey @A Former User
              last edited by

              @iamlamprey Yes, but you'd still need to tinker with C++ to add the functionality to the CLI.

              Libre Wave - Freedom respecting instruments and effects
              My Patreon - HISE tutorials
              YouTube Channel - Public HISE tutorials

              1 Reply Last reply Reply Quote 0
              • ?
                A Former User
                last edited by

                Yeh idk the amount of time it would take me to get it is likely going to be much larger than individually converting the wavetables 🤷

                d.healeyD 2 Replies Last reply Reply Quote 0
                • d.healeyD
                  d.healey @A Former User
                  last edited by

                  @iamlamprey Many a time I've spent a day or more trying to add something in C++ - depends on how badly you want it :)

                  Libre Wave - Freedom respecting instruments and effects
                  My Patreon - HISE tutorials
                  YouTube Channel - Public HISE tutorials

                  1 Reply Last reply Reply Quote 1
                  • d.healeyD
                    d.healey @A Former User
                    last edited by d.healey

                    @iamlamprey said in Bulk Convert SampleMaps to WaveTables:

                    This next part is from a different function so I assume I can't access the result of it

                    PoolReference ref(chain->getMainController(), comboBoxThatHasChanged->getText(), FileHandlerBase::SampleMaps);

                    You'll need to use something like this to loop through all of the sample maps. Then pass the sample map file to the convert to wavetable function. Doesn't look like it should be too complicated actually, but no idea until it's tried.

                    Libre Wave - Freedom respecting instruments and effects
                    My Patreon - HISE tutorials
                    YouTube Channel - Public HISE tutorials

                    1 Reply Last reply Reply Quote 0
                    • d.healeyD
                      d.healey
                      last edited by

                      Ok so this is a guess (I've done no testing). You would call this function from your Bulk Convert button's callback.

                      	void bulkConvertSampleMapsToWavetables()
                      	{
                      		auto& spool = chain->getMainController()->getActiveFileHandler()->pool->getSampleMapPool();
                      		
                      		for (int i = 0; i < list.size; i++)
                      		{
                      			PoolReference ref(chain->getMainController(), list[i], FileHandlerBase::SampleMaps);
                      			currentlyLoadedMap = ref.getFile().getFileNameWithoutExtension();
                      			
                      			if (auto vData = spool.loadFromReference(ref, PoolHelpers::LoadAndCacheWeak))
                      			{
                      				converter->parseSampleMap(*vData.getData());
                      
                      				if (currentMode == FFTResynthesis)
                      				{
                      					converter->refreshCurrentWavetable(getProgressCounter());
                      					
                      				}
                      				
                      				refreshPreview(); 
                      			}
                      		}	
                      	}
                      

                      Libre Wave - Freedom respecting instruments and effects
                      My Patreon - HISE tutorials
                      YouTube Channel - Public HISE tutorials

                      ? 1 Reply Last reply Reply Quote 1
                      • ?
                        A Former User @d.healey
                        last edited by

                        @d-healey Insane. I wasn't anywhere close to that lmao

                        I'll try and build it tomorrow, officially past my bed time in aus :)

                        orangeO 1 Reply Last reply Reply Quote 1
                        • orangeO
                          orange @A Former User
                          last edited by

                          @iamlamprey For a smooth interpolation between the waves, is there any limit of the wave numbers? I remember that you said that you are getting artifacts for this?

                          develop Branch / XCode 13.1
                          macOS Monterey / M1 Max

                          Christoph HartC 1 Reply Last reply Reply Quote 0
                          • Christoph HartC
                            Christoph Hart @orange
                            last edited by

                            @orange if you enable hq mode, it already interpolates between the tables.

                            orangeO 1 Reply Last reply Reply Quote 1
                            • orangeO
                              orange @Christoph Hart
                              last edited by

                              @Christoph-Hart said in Bulk Convert SampleMaps to WaveTables:

                              @orange if you enable hq mode, it already interpolates between the tables.

                              Great to know that. Thanks!

                              develop Branch / XCode 13.1
                              macOS Monterey / M1 Max

                              1 Reply Last reply Reply Quote 0
                              • ?
                                A Former User
                                last edited by

                                Okay using @d-healey 's script as a starting point, I can get it looping through the sampleMaps and everything, but it's currently not "clearing" the file each time it iterates, so the wavetables get larger and larger (and i assume sound terrible)

                                350fb7b9-0dbe-4d51-8ee6-36eb825e0c5c-image.png

                                I also got rid of the right side since it doesn't work anyway:

                                void bulkConvertSampleMapsToWavetables()
                                	{
                                		auto& spool = chain->getMainController()->getActiveFileHandler()->pool->getSampleMapPool();
                                		auto& list = chain->getMainController()->getActiveFileHandler()->pool->getSampleMapPool().getIdList();
                                
                                		for (int i = 0; i < list.size(); i++)
                                		{
                                			currentlyLoadedMap = "";
                                
                                			PoolReference ref(chain->getMainController(), list[i], FileHandlerBase::SampleMaps);
                                			currentlyLoadedMap = ref.getFile().getFileNameWithoutExtension();
                                
                                			if (currentMode == FFTResynthesis)
                                				converter->renderAllWavetablesFromHarmonicMaps(getProgressCounter());
                                			else
                                				converter->renderAllWavetablesFromSingleWavetables(getProgressCounter());
                                
                                			if (threadShouldExit())
                                				return;
                                
                                			auto leftTree = converter->getValueTree(true);
                                
                                			auto fileL = currentlyLoadedMap + "_Left.hwt";
                                
                                			auto tfl = GET_PROJECT_HANDLER(chain).getSubDirectory(ProjectHandler::SubDirectories::AudioFiles).getChildFile(fileL);
                                
                                			PresetHandler::writeValueTreeAsFile(leftTree, tfl.getFullPathName());
                                		}
                                	}
                                

                                I can't see any reason why it wouldn't clear the samplemap each time, I even added an empty string at the start of the loop to clear it but idk

                                d.healeyD 1 Reply Last reply Reply Quote 0
                                • d.healeyD
                                  d.healey @A Former User
                                  last edited by

                                  @iamlamprey I assume the renderAllWaveTables... functions are doing something to all the wavetables in the folder and creating a new wavetable, then when it loops again there are two wavetables being processed, then 3, then 4, etc.

                                  I don't think it has anything to do with currentLoadedMap.

                                  Libre Wave - Freedom respecting instruments and effects
                                  My Patreon - HISE tutorials
                                  YouTube Channel - Public HISE tutorials

                                  ? 1 Reply Last reply Reply Quote 0
                                  • ?
                                    A Former User @d.healey
                                    last edited by

                                    @d-healey Yeah so close now, I moved it out of the for loop which solved the size problem, but now all of the wavetables are the same 😂

                                    So i think it has to do with making renderAllWaveTables reset each time or something

                                    d.healeyD 1 Reply Last reply Reply Quote 0
                                    • d.healeyD
                                      d.healey @A Former User
                                      last edited by

                                      @iamlamprey What does renderAllWaveTables do?

                                      Libre Wave - Freedom respecting instruments and effects
                                      My Patreon - HISE tutorials
                                      YouTube Channel - Public HISE tutorials

                                      ? 1 Reply Last reply Reply Quote 0
                                      • ?
                                        A Former User @d.healey
                                        last edited by

                                        @d-healey i think it's the actual conversion part, the rest is just writing the result to a file

                                        void SampleMapToWavetableConverter::renderAllWavetablesFromSingleWavetables(double& progress)
                                        {
                                        	using Data = ResynthesisHelpers::SimpleNoteConversionData;
                                        
                                        	for (int i = 0; i < 128; i++)
                                        	{
                                        		Array<Data> conversionData;
                                        
                                        		for (auto s : sampleMap)
                                        		{
                                        			int loKey = s.getProperty(SampleIds::LoKey, -1);
                                        			int hiKey = s.getProperty(SampleIds::HiKey, -1);
                                        			int root = s.getProperty(SampleIds::Root, -1);
                                        
                                        			if (i >= loKey && i <= hiKey)
                                        			{
                                        				auto thisFreq = MidiMessage::getMidiNoteInHertz(i);
                                        				auto rootFreq = MidiMessage::getMidiNoteInHertz(root);
                                        
                                        
                                        				auto fName = s.getProperty(SampleIds::FileName).toString();
                                        
                                        				if (fName.isEmpty())
                                        					s.getChild(0).getProperty(SampleIds::FileName).toString();
                                        
                                        				PoolReference r(chain->getMainController(), fName, FileHandlerBase::Samples);
                                        
                                        				Data data;
                                        				data.sampleFile = r.getFile();
                                        				data.rootRatio = thisFreq / rootFreq;
                                        				data.noteNumber = i;
                                        				data.veloRange.setStart((int)s.getProperty(SampleIds::LoVel, 0));
                                        				data.veloRange.setEnd((int)s.getProperty(SampleIds::HiVel, 127) + 1);
                                        
                                        				conversionData.insert(-1, data);
                                        			}
                                        		}
                                        
                                        		progress = (double)i / 128.0;
                                        
                                        		if (conversionData.isEmpty())
                                        			continue;
                                        
                                        		struct DataSorter
                                        		{
                                        			int compareElements(Data& first, Data& second)
                                        			{
                                        				if (first.veloRange.getStart() < second.veloRange.getStart())
                                        					return -1;
                                        
                                        				if (first.veloRange.getStart() > second.veloRange.getStart())
                                        					return 1;
                                        
                                        				return 0;
                                        			}
                                        		};
                                        
                                        		DataSorter sorter;
                                        
                                        		conversionData.sort(sorter);
                                        
                                        
                                        		auto output = ResynthesisHelpers::loadAndResampleAudioFilesForVelocity(conversionData, sampleRate);
                                        
                                        		storeData(i, output.getWritePointer(0), leftValueTree, output.getNumSamples(), conversionData.size());
                                        
                                        		if (output.getNumChannels() == 2)
                                        		{
                                        			storeData(i, output.getWritePointer(1), rightValueTree, output.getNumSamples(), conversionData.size());
                                        		}
                                        	}
                                        }
                                        
                                        d.healeyD 1 Reply Last reply Reply Quote 0
                                        • d.healeyD
                                          d.healey @A Former User
                                          last edited by

                                          @iamlamprey I think you might need to wait for some Christoph input

                                          Libre Wave - Freedom respecting instruments and effects
                                          My Patreon - HISE tutorials
                                          YouTube Channel - Public HISE tutorials

                                          ? 1 Reply Last reply Reply Quote 0
                                          • ?
                                            A Former User @d.healey
                                            last edited by

                                            @d-healey all good, ill keep noodling in the meantime :) cheers

                                            1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post

                                            7

                                            Online

                                            1.8k

                                            Users

                                            12.1k

                                            Topics

                                            104.9k

                                            Posts