feat: load soundfont in nodejs
This commit is contained in:
		
							parent
							
								
									c96a6b69dd
								
							
						
					
					
						commit
						36a05aac75
					
				
					 1 changed files with 11 additions and 1 deletions
				
			
		|  | @ -56,8 +56,18 @@ const initFonts = () => { | |||
| export const loadSoundFont = (score: WebMscore): Promise<void> => { | ||||
|   if (!score[SOUND_FONT_LOADED]) { | ||||
|     const loadPromise = (async () => { | ||||
|       let data: Uint8Array | ||||
|       if (isNodeJs) { | ||||
|         // module.exports.FluidR3Mono = ...
 | ||||
|         const SF3 = Object.values(require('@librescore/sf3'))[0] | ||||
|         const fs = require('fs') | ||||
|         data = await fs.promises.readFile(SF3) | ||||
|       } else { | ||||
|         data = await fetchData(SF3_URL) | ||||
|       } | ||||
| 
 | ||||
|       await score.setSoundFont( | ||||
|         await fetchData(SF3_URL), | ||||
|         data, | ||||
|       ) | ||||
|     })() | ||||
|     score[SOUND_FONT_LOADED] = loadPromise | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue