[CSOUND-DEV] FluidSynth without using midiNN
Date | 2015-10-19 12:50 |
From | Peter Burgess |
Subject | [CSOUND-DEV] FluidSynth without using midiNN |
Hi there, is there any way of playing fluidSynth without using midi note numbers? My project involves a whole range of different temperaments, and so all my instruments are played using Hz, not midiNN. Or are there any alternatives in csound (besides the old soundfont opcodes, which I will explore if I can't find any other way)? I'm assuming not, I'm guessing they would be listen in the quick reference if they were. |
Date | 2015-10-19 13:23 |
From | Michael Gogins |
Subject | Re: [CSOUND-DEV] FluidSynth without using midiNN |
It was stupid of the FluidSynth developers not to make all MIDI numbers floating-point numbers, but they are far from alone. However, you can still use alternative tuning systems with FluidSynth, though it is a bit of a hack. You assign each of your pitches to a MIDI channel and MIDI note number, then detune that channel and number to the frequency that you need. You can play any tuning system at all this way. The conversions between MIDI key numbers and frequencies are simple and can be found here: https://newt.phys.unsw.edu.au/jw/notes.html. Both of these formulas will work with fractional MIDI note numbers. In Csound, you can use cpsmidinn to obtain frequencies from MIDI key numbers, including fractions. Here is the Csound code for the opposite conversion: opcode hertz2midinn, i, i ihertz xin print ihertz ; m = 12*log2(fm/440 Hz) + 69 ilog2 = log(2) imidinn = 12 * (log(ihertz / 440) / ilog2) + 69 print imidinn xout imidinn endop In my own compositions, I use exclusively MIDI note numbers to represent pitch, but I sometimes use fractional MIDI key numbers to obtain different tuning systems. Obviously this is much easier in pure Csound code. Typically I use a ratio to represent a scale degree, then I start with a root frequency and add octaves to get the actual note frequency, which I convert to a fractional MIDI key number and send to the Csound instrument. This works just fine. ----------------------------------------------------- Michael Gogins Irreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Mon, Oct 19, 2015 at 7:50 AM, Peter Burgess |
Date | 2015-10-19 13:45 |
From | Peter Burgess |
Subject | Re: [CSOUND-DEV] FluidSynth without using midiNN |
Yes sorry, it occured to me after sending the message that I can just write the conversion in myself. I've stuck it in just before the scores are written in c++, which is really crude and messy. I keep forgetting though that I can just write a UDO to do things that csound doesn't have opcodes for, that is a much better solution. While on the subject of fluidSynth and memory, it works fine from my test .csd, but if I put the exact same instr definition into my app's instrument string and try to use the fluidSynth instrument, I get this error (and I've included the line underneath because it might be relevant):The hack fix sounds daunting, mostly because I fear it's yet another element to write into my app :D I will give it a go though, it's probably not as bigger deal as I'm thinking, and will be well worth the effort if it works. I am planning on eventually being able to create full orchestral pieces of music with my program. I don't know if this will be done entirely in fluidSynth yet, but If I was to make microtonal orchestral pieces with fluidSynth alone using the midiNN to different channels hack you mentioned, do you think I will need to use more than one fluidSynth engine? Or are there any other considerations like memory etc I will have to face up to? fluidsynth: warning: Failed to pin the sample data to RAM; swapping is possible. fluidSynth: 0x0x38bb640 soundFontId: 1. gifluidengine fluidEngine 0, 1, 2, 256 isfont0 fluidLoad "csound/soundfonts/Clean_Guitar.sf2", gifluidengine fluidProgramSelect gifluidengine, 0, isfont0, 0, 0 instr 7001 imidikey = p4 imidivel = 127 fluidNote gifluidengine, 0, imidikey, imidivel endin instr 12999 aleft, aright fluidAllOut outs aleft, aright endin On Mon, Oct 19, 2015 at 1:23 PM, Michael Gogins <michael.gogins@gmail.com> wrote: It was stupid of the FluidSynth developers not to make all MIDI |
Date | 2015-10-19 13:52 |
From | jpff |
Subject | Re: [CSOUND-DEV] FluidSynth without using midiNN |
Or use log2() function? On Mon, 19 Oct 2015, Michael Gogins wrote: > ilog2 = log(2) |
Date | 2015-10-19 14:52 |
From | Michael Gogins |
Subject | Re: [CSOUND-DEV] FluidSynth without using midiNN |
"Full orchestral pieces" is a bit ambiguous. Do you mean emulations of the traditional orchestra and its instruments, or music of comparable complexity and depth but using synthetic textures that do not necessarily sound like fiddles etc, or what? FluidSynth is useful but it is not capable of producing textures of truly orchestral quality and depth. This is an extremely demanding standard, and most electroacoustic music, computer music, electronic music also falls short of this standard. If you mean emulating the traditional orchestra, look to the leading film and game music composers for how to do this. It usually involves a room (literally) full of hard disks full of samples of traditional instruments. You can buy sample sets for this purpose, some of them are pretty good, those are usually not cheap and take up a lot of storage. They're designed to be used from Sibelius, Finale, Pro Tools, etc. Believe me these things sound a lot better than FluidSynth. Duplicating this in Csound on Windows would not be possible because they use memory-mapped sample sets, which Csound does not currently support. It would also be a hell of a lot of work. I think there are VST sample sets that would give you a real leg up here. But on Windows you would still need a 64 bit built of Csound, which doesn't exist yet, although it is probably not far off. OS X would be the way to go because Csound is 64 bits and all the good commercial music software and sample sets also runs on OS X. Csound on Linux is also 64 bits. If you mean synthetic sounds of equivalent depth and quality, among those who have done best in this department, focusing on 'instrumental' textures, are James Dashow (mostly custom hardware synths controlled by custom software), Robert Normandeau (mostly working in Pro Tools with samples and processing, as far as I know), later Wendy Carlos (hardware synths with custom tuning systems), Barry Schrader (instruments deliberately not specified), Eric Lyon (variously Csound, Max, etc.), Paul Lansky (Cmix, software synthesizer written by him, same sort of beast as Csound but you have to write instruments in C++).. I am sure there are many others, these are just some of the ones I have listened to most. The reason so many of these use hardware not software is partly a historical accident, capable hardware came before capable software, partly that the hardware usually comes with pretty good patches as a starting point, and partly that to experienced ears hardware oscillators and filters literally sound a bit different -- think "snap" instead of "click." No software synthesizer would be any better than Csound in this department. It would be a lengthy discussion, how best to do this, starting with what you really mean -- do you have some example pieces, from you or anyone else, that would represent what you are aiming for? Regards, Mike ----------------------------------------------------- Michael Gogins Irreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Mon, Oct 19, 2015 at 8:52 AM, jpff |
Date | 2015-10-19 15:55 |
From | Peter Burgess |
Subject | Re: [CSOUND-DEV] FluidSynth without using midiNN |
Cheers mike for that truly thorough answer! You're pretty good at answering questions I didn't realise I'd asked but clearly need answers to all the same ;) I do really appreciate you taking the time to give such rich explanations. I'll start with my "orchestral" goals. To put a quick end to my ambiguity, I'm going to give a rough figure of 10 instruments. After some thought, there probably isn't much need for me to stretch far beyond 10 instruments to make my orchestral pieces. This would allow me to do microtonal tunings with up to 25 divides per octave with 10 instruments over the 256 channels on one fluidEngine. I guess my only question then is how demanding this would be on memory and cpu?Next let's talk envirenment. I am building my app in linux, but I want my app to be available to all major desktop and mobile platforms. The mobile platforms are particularly important for my project. It's worth mentioning that all audio in csound is currently happening behind the scenes. Currently, it is all being exported to wav and then the wav is played in SDL_mixer for "realtime" playback. There is no user control of the instruments, only c++ control. This buys me some extra headroom in terms of performance on mobile devices, but as for storage space for samples, I will need to be careful. Thanks again for your help, Pete On Mon, Oct 19, 2015 at 2:52 PM, Michael Gogins <michael.gogins@gmail.com> wrote: "Full orchestral pieces" is a bit ambiguous. Do you mean emulations of |
Date | 2015-10-19 16:29 |
From | Michael Gogins |
Subject | Re: [CSOUND-DEV] FluidSynth without using midiNN |
OK, much clearer now. You will not get realistic emulations of every orchestral instrument with physical models, but using them would really simplify your project, so if you just need placeholders use the STK opcodes, physical models, and other Csound instruments. I have not researched whether sample sets have good support for alternative tunings, but that might be worth researching. You are aware that Csound can host VST plugins (and, on OS X and Linux, other kinds of plugins)? But this would problematic on mobile devices. Regards, Mike ----------------------------------------------------- Michael Gogins Irreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Mon, Oct 19, 2015 at 10:55 AM, Peter Burgess |
Date | 2015-10-19 16:50 |
From | Peter Burgess |
Subject | Re: [CSOUND-DEV] FluidSynth without using midiNN |
Hmm, ok, that's definitely worth thinking about! Is that problematic from a resource perspective or a compatability perspective? On Mon, Oct 19, 2015 at 4:29 PM, Michael Gogins <michael.gogins@gmail.com> wrote: OK, much clearer now. |
Date | 2015-10-19 18:01 |
From | Michael Gogins |
Subject | Re: [CSOUND-DEV] FluidSynth without using midiNN |
Problematic in that as far as I know, mobile software does not support loading VST plugins. Perhaps I'm wrong. There are enough resources on high-end devices. The plugins themselves would have to be compiled for Android or iOS, of course. As far as I know this is not being done. Regards, Mike ----------------------------------------------------- Michael Gogins Irreducible Productions http://michaelgogins.tumblr.com Michael dot Gogins at gmail dot com On Mon, Oct 19, 2015 at 11:50 AM, Peter Burgess |
Date | 2015-10-19 18:08 |
From | Peter Burgess |
Subject | Re: [CSOUND-DEV] FluidSynth without using midiNN |
Right! Cool, it's probably worth me doing my research on the VST front then. Where does fluidSynth stand in all this? Will that run on mobile? Is it a different deal to VST's? Could a different soundfont player (that readily allows microtonal tunings) be integrated into Csound? This is something currently beyond my capabilities (at least without more effort than I can afford right now) but it's good to get an idea early on which direction I should go. Chers for your help mike!On Mon, Oct 19, 2015 at 6:01 PM, Michael Gogins <michael.gogins@gmail.com> wrote: Problematic in that as far as I know, mobile software does not support |