Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #36667 > unrolled thread
| Started by | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| First post | 2019-05-29 06:43 -0700 |
| Last post | 2019-06-01 07:05 -0700 |
| Articles | 14 — 5 participants |
Back to article view | Back to comp.lang.javascript
Read in cakewalk instrument files banks and their content and hold in coherent manner. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-05-29 06:43 -0700
Re: Read in cakewalk instrument files banks and their content and hold in coherent manner. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-06-01 04:26 -0700
Re: Read in cakewalk instrument files banks and their content and hold in coherent manner. JJ <jj4public@vfemail.net> - 2019-06-02 09:28 +0700
Re: Read in cakewalk instrument files banks and their content and hold in coherent manner. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-06-01 23:23 -0700
Re: Read in cakewalk instrument files banks and their content and hold in coherent manner. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-06-01 23:26 -0700
Re: Read in cakewalk instrument files banks and their content and hold in coherent manner. JJ <jj4public@vfemail.net> - 2019-06-03 10:51 +0700
Re: Read in cakewalk instrument files banks and their content and hold in coherent manner. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-06-02 22:32 -0700
Re: Read in cakewalk instrument files banks and their content and hold in coherent manner. Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> - 2019-06-03 11:43 +0300
Re: Read in cakewalk instrument files banks and their content and hold in coherent manner. dr.j.r.stockton@gmail.com - 2019-06-03 02:31 -0700
Re: Read in cakewalk instrument files banks and their content and hold in coherent manner. "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2019-06-03 12:25 +0200
Re: Read in cakewalk instrument files banks and their content and hold in coherent manner. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-06-03 04:07 -0700
Re: Read in cakewalk instrument files banks and their content and hold in coherent manner. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-06-01 04:27 -0700
Re: Read in cakewalk instrument files banks and their content and hold in coherent manner. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-06-01 07:04 -0700
Re: Read in cakewalk instrument files banks and their content and hold in coherent manner. Jonas Thörnvall <jonas.thornvall@gmail.com> - 2019-06-01 07:05 -0700
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2019-05-29 06:43 -0700 |
| Subject | Read in cakewalk instrument files banks and their content and hold in coherent manner. |
| Message-ID | <30b489af-8a97-43be-9ef8-94da87ce7d7a@googlegroups.com> |
Well i skipped creating any object probably for the better, it reads in bank names in arrays and list array in the bank option list. The same with respective instruments in bank.
And at change read in the instrument for bank in question into the option list for the bank selected, just by split the string iont array "and tweaking empty lines not perfect". Simple is better.... or....
Yeah i know it will do it everytime.... Well that had only been once with an object but added complexity, that i am not the man to handle. I also fixed so one can read in other instrument files but "my KORG N364" is default.
Now it is just to send the message for bank chosen to synth, depending on selection.
function splitInstrumentFile(ATXT){
bankName=[];
var PatchStart = ATXT.indexOf(".Patch Names",0);
var NoteStart = ATXT.indexOf(".Note Names",0);
var allBANKS=ATXT.substring(PatchStart+12,NoteStart);
listBanks(allBANKS);
}
function listBanks(allBANKS){
console.log("Write out just the banks"+allBANKS);
Abank = allBANKS.split("[");
Abank.shift();
for(i=0;i<Abank.length;i++){
//alert(Abank[i]);
getBankName(i);
}
//alert(bankName);
bankOptionList();
defaultBank=1;
document.getElementById("selBank").selectedIndex = defaultBank;
ListBankInstruments(defaultBank);
}
function getBankName(i){
var ENDBANKNAME = Abank[i].indexOf("]",0);
bankName[i]=Abank[i].substring(0,ENDBANKNAME);
}
function ListBankInstruments(current){
//REMOVE EMPTY LINES FROM BANK
Abank[current]=Abank[current].replace(/^\s*[\r]/gm,"");
//SPLIT BANK INTO ARRAY OF INSTRUMENTS
instName=Abank[current].split("\n");
//REMOVE FIRST LINE "BANKNAME"
instName.shift();
//alert(instName);
instOptionList();
}
function bankSelection(){
current=document.getElementById("selBank").selectedIndex;
ListBankInstruments(current);
}
[toc] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2019-06-01 04:26 -0700 |
| Message-ID | <e531b0b1-208e-419b-85bb-872955d62e50@googlegroups.com> |
| In reply to | #36667 |
Den onsdag 29 maj 2019 kl. 15:43:26 UTC+2 skrev Jonas Thörnvall:
> Well i skipped creating any object probably for the better, it reads in bank names in arrays and list array in the bank option list. The same with respective instruments in bank.
>
> And at change read in the instrument for bank in question into the option list for the bank selected, just by split the string iont array "and tweaking empty lines not perfect". Simple is better.... or....
>
> Yeah i know it will do it everytime.... Well that had only been once with an object but added complexity, that i am not the man to handle. I also fixed so one can read in other instrument files but "my KORG N364" is default.
>
> Now it is just to send the message for bank chosen to synth, depending on selection.
>
> function splitInstrumentFile(ATXT){
> bankName=[];
> var PatchStart = ATXT.indexOf(".Patch Names",0);
> var NoteStart = ATXT.indexOf(".Note Names",0);
> var allBANKS=ATXT.substring(PatchStart+12,NoteStart);
> listBanks(allBANKS);
> }
>
> function listBanks(allBANKS){
> console.log("Write out just the banks"+allBANKS);
> Abank = allBANKS.split("[");
> Abank.shift();
> for(i=0;i<Abank.length;i++){
> //alert(Abank[i]);
> getBankName(i);
> }
> //alert(bankName);
> bankOptionList();
> defaultBank=1;
> document.getElementById("selBank").selectedIndex = defaultBank;
> ListBankInstruments(defaultBank);
> }
>
> function getBankName(i){
> var ENDBANKNAME = Abank[i].indexOf("]",0);
> bankName[i]=Abank[i].substring(0,ENDBANKNAME);
> }
>
> function ListBankInstruments(current){
> //REMOVE EMPTY LINES FROM BANK
> Abank[current]=Abank[current].replace(/^\s*[\r]/gm,"");
> //SPLIT BANK INTO ARRAY OF INSTRUMENTS
> instName=Abank[current].split("\n");
> //REMOVE FIRST LINE "BANKNAME"
> instName.shift();
> //alert(instName);
> instOptionList();
> }
>
> function bankSelection(){
> current=document.getElementById("selBank").selectedIndex;
> ListBankInstruments(current);
> }
Well i replaced the regex with string function on arrayelements, its not perfect but good enough for use, time for send the bankchange and programchange.
[toc] | [prev] | [next] | [standalone]
| From | JJ <jj4public@vfemail.net> |
|---|---|
| Date | 2019-06-02 09:28 +0700 |
| Message-ID | <1ovdybefl3zg5$.1txcn41x377u4$.dlg@40tude.net> |
| In reply to | #36726 |
On Sat, 1 Jun 2019 04:26:44 -0700 (PDT), Jonas Thörnvall wrote: >> //REMOVE EMPTY LINES FROM BANK >> Abank[current]=Abank[current].replace(/^\s*[\r]/gm,""); That clears the unwanted lines, instead of removing them.
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2019-06-01 23:23 -0700 |
| Message-ID | <09b80eaf-4e43-4f99-b8f7-de0440a9c4c4@googlegroups.com> |
| In reply to | #36737 |
Den söndag 2 juni 2019 kl. 04:28:27 UTC+2 skrev JJ:
> On Sat, 1 Jun 2019 04:26:44 -0700 (PDT), Jonas Thörnvall wrote:
> >> //REMOVE EMPTY LINES FROM BANK
> >> Abank[current]=Abank[current].replace(/^\s*[\r]/gm,"");
>
> That clears the unwanted lines, instead of removing them.
I removed replace regex with splice.
function ListBankInstruments(current){
instName=Abank[current].split("\n");[]
//REMOVE FIRST LINE "BANKNAME"
instName.shift();
//REMOVE LINES NOT STARTING WITH DIGIT OR EMPTY
alert(instName[instName.length-1].charCodeAt(0));
for (var j=instName.length-1;j>=0;j--){
ChCode=instName[j].charCodeAt(0);
if (ChCode<48 || ChCode>57 || ChCode==13 ) { instName.splice(j,1); }
}
alert(instName.length);
instOptionList();
}
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2019-06-01 23:26 -0700 |
| Message-ID | <5ab0dc7f-e55d-421b-9cee-e514eaf11967@googlegroups.com> |
| In reply to | #36738 |
Den söndag 2 juni 2019 kl. 08:24:08 UTC+2 skrev Jonas Thörnvall:
> Den söndag 2 juni 2019 kl. 04:28:27 UTC+2 skrev JJ:
> > On Sat, 1 Jun 2019 04:26:44 -0700 (PDT), Jonas Thörnvall wrote:
> > >> //REMOVE EMPTY LINES FROM BANK
> > >> Abank[current]=Abank[current].replace(/^\s*[\r]/gm,"");
> >
> > That clears the unwanted lines, instead of removing them.
>
> I removed replace regex with splice.
>
> function ListBankInstruments(current){
> instName=Abank[current].split("\n");[]
> //REMOVE FIRST LINE "BANKNAME"
> instName.shift();
> //REMOVE LINES NOT STARTING WITH DIGIT OR EMPTY
> alert(instName[instName.length-1].charCodeAt(0));
>
> for (var j=instName.length-1;j>=0;j--){
> ChCode=instName[j].charCodeAt(0);
> if (ChCode<48 || ChCode>57 || ChCode==13 ) { instName.splice(j,1); }
> }
> alert(instName.length);
> instOptionList();
> }
Sorry i exchanged... and removed
[toc] | [prev] | [next] | [standalone]
| From | JJ <jj4public@vfemail.net> |
|---|---|
| Date | 2019-06-03 10:51 +0700 |
| Message-ID | <7jx4aeorejtf$.1885sn14ulrfm$.dlg@40tude.net> |
| In reply to | #36739 |
On Sat, 1 Jun 2019 23:26:08 -0700 (PDT), Jonas Thörnvall wrote:
>>
>> if (ChCode<48 || ChCode>57 || ChCode==13 ) ...
The `split("\n")` already removed all LF characters, so `ChCode==13` will
always be `false`.
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2019-06-02 22:32 -0700 |
| Message-ID | <c0cff65d-e500-462d-86e6-9b81ffab0f3e@googlegroups.com> |
| In reply to | #36744 |
Den måndag 3 juni 2019 kl. 05:51:54 UTC+2 skrev JJ:
> On Sat, 1 Jun 2019 23:26:08 -0700 (PDT), Jonas Thörnvall wrote:
> >>
> >> if (ChCode<48 || ChCode>57 || ChCode==13 ) ...
>
> The `split("\n")` already removed all LF characters, so `ChCode==13` will
> always be `false`.
Even if they last in textblock?
[toc] | [prev] | [next] | [standalone]
| From | Jukka Lahtinen <jtfjdehf@hotmail.com.invalid> |
|---|---|
| Date | 2019-06-03 11:43 +0300 |
| Message-ID | <m38suj3vqj.fsf@sonera.fi> |
| In reply to | #36744 |
JJ <jj4public@vfemail.net> writes:
> On Sat, 1 Jun 2019 23:26:08 -0700 (PDT), Jonas Thörnvall wrote:
>>> if (ChCode<48 || ChCode>57 || ChCode==13 ) ...
> The `split("\n")` already removed all LF characters, so `ChCode==13` will
> always be `false`.
Besides, ChCode<48 already covers the case of ChCode==13.
--
Jukka Lahtinen
[toc] | [prev] | [next] | [standalone]
| From | dr.j.r.stockton@gmail.com |
|---|---|
| Date | 2019-06-03 02:31 -0700 |
| Message-ID | <35280ce5-1dd4-406a-bd87-4d1582fbf524@googlegroups.com> |
| In reply to | #36744 |
On Monday, 3 June 2019 04:51:54 UTC+1, JJ wrote:
> On Sat, 1 Jun 2019 23:26:08 -0700 (PDT), Jonas Thörnvall wrote:
> >>
> >> if (ChCode<48 || ChCode>57 || ChCode==13 ) ...
>
> The `split("\n")` already removed all LF characters, so `ChCode==13` will
> always be `false`.
AFAIK, 13 < 48, so that the third test is redundant - but ICBW.
--
(c) John Stockton, near London, UK. Using Google Groups. |
Mail: J.R.""""""""@physics.org - or as Reply-To, if any. |
[toc] | [prev] | [next] | [standalone]
| From | "Evertjan." <exxjxw.hannivoort@inter.nl.net> |
|---|---|
| Date | 2019-06-03 12:25 +0200 |
| Message-ID | <XnsAA637E592E66eejj99@194.109.6.166> |
| In reply to | #36747 |
dr.j.r.stockton@gmail.com wrote on 03 Jun 2019 in comp.lang.javascript: > AFAIK, 13 < 48, ... This must also be true in Scandinavia, but will it be Down-Under, or even in London during Trump's visit? -- Evertjan. The Netherlands. (Please change the x'es to dots in my emailaddress)
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2019-06-03 04:07 -0700 |
| Message-ID | <e4f5b5e4-d9cd-4fc9-8121-746439394cfe@googlegroups.com> |
| In reply to | #36747 |
Den måndag 3 juni 2019 kl. 11:32:01 UTC+2 skrev dr.j.r...@gmail.com:
> On Monday, 3 June 2019 04:51:54 UTC+1, JJ wrote:
> > On Sat, 1 Jun 2019 23:26:08 -0700 (PDT), Jonas Thörnvall wrote:
> > >>
> > >> if (ChCode<48 || ChCode>57 || ChCode==13 ) ...
> >
> > The `split("\n")` already removed all LF characters, so `ChCode==13` will
> > always be `false`.
>
> AFAIK, 13 < 48, so that the third test is redundant - but ICBW.
>
> --
> (c) John Stockton, near London, UK. Using Google Groups. |
> Mail: J.R.""""""""@physics.org - or as Reply-To, if any. |
Yeah you could be right ;), if it ain't numeric in ain't there. But maybe it will remove the ghosts.
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2019-06-01 04:27 -0700 |
| Message-ID | <ccf292c5-8f7b-4190-a93f-cc7f68ddd198@googlegroups.com> |
| In reply to | #36667 |
Den onsdag 29 maj 2019 kl. 15:43:26 UTC+2 skrev Jonas Thörnvall:
> Well i skipped creating any object probably for the better, it reads in bank names in arrays and list array in the bank option list. The same with respective instruments in bank.
>
> And at change read in the instrument for bank in question into the option list for the bank selected, just by split the string iont array "and tweaking empty lines not perfect". Simple is better.... or....
>
> Yeah i know it will do it everytime.... Well that had only been once with an object but added complexity, that i am not the man to handle. I also fixed so one can read in other instrument files but "my KORG N364" is default.
>
> Now it is just to send the message for bank chosen to synth, depending on selection.
>
> function splitInstrumentFile(ATXT){
> bankName=[];
> var PatchStart = ATXT.indexOf(".Patch Names",0);
> var NoteStart = ATXT.indexOf(".Note Names",0);
> var allBANKS=ATXT.substring(PatchStart+12,NoteStart);
> listBanks(allBANKS);
> }
>
> function listBanks(allBANKS){
> console.log("Write out just the banks"+allBANKS);
> Abank = allBANKS.split("[");
> Abank.shift();
> for(i=0;i<Abank.length;i++){
> //alert(Abank[i]);
> getBankName(i);
> }
> //alert(bankName);
> bankOptionList();
> defaultBank=1;
> document.getElementById("selBank").selectedIndex = defaultBank;
> ListBankInstruments(defaultBank);
> }
>
> function getBankName(i){
> var ENDBANKNAME = Abank[i].indexOf("]",0);
> bankName[i]=Abank[i].substring(0,ENDBANKNAME);
> }
>
> function ListBankInstruments(current){
> //REMOVE EMPTY LINES FROM BANK
> Abank[current]=Abank[current].replace(/^\s*[\r]/gm,"");
> //SPLIT BANK INTO ARRAY OF INSTRUMENTS
> instName=Abank[current].split("\n");
> //REMOVE FIRST LINE "BANKNAME"
> instName.shift();
> //alert(instName);
> instOptionList();
> }
>
> function bankSelection(){
> current=document.getElementById("selBank").selectedIndex;
> ListBankInstruments(current);
> }
function ListBankInstruments(current){
instName=Abank[current].split("\n");[]
//REMOVE FIRST LINE "BANKNAME"
instName.shift();
//REMOVE LINES NOT STARTING WITH DIGIT OR EMPTY
for (var j=instName.length-1;j>=0;j--){
ChCode=instName[j].charCodeAt(0);
if (ChCode<48 || ChCode>57 || ChCode==13 ) { instName.splice(j,1); }
}
instOptionList();
}
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2019-06-01 07:04 -0700 |
| Message-ID | <d02bf8c1-bf62-43cb-b500-9f4112e3834a@googlegroups.com> |
| In reply to | #36667 |
Den onsdag 29 maj 2019 kl. 15:43:26 UTC+2 skrev Jonas Thörnvall:
> Well i skipped creating any object probably for the better, it reads in bank names in arrays and list array in the bank option list. The same with respective instruments in bank.
>
> And at change read in the instrument for bank in question into the option list for the bank selected, just by split the string iont array "and tweaking empty lines not perfect". Simple is better.... or....
>
> Yeah i know it will do it everytime.... Well that had only been once with an object but added complexity, that i am not the man to handle. I also fixed so one can read in other instrument files but "my KORG N364" is default.
>
> Now it is just to send the message for bank chosen to synth, depending on selection.
>
> function splitInstrumentFile(ATXT){
> bankName=[];
> var PatchStart = ATXT.indexOf(".Patch Names",0);
> var NoteStart = ATXT.indexOf(".Note Names",0);
> var allBANKS=ATXT.substring(PatchStart+12,NoteStart);
> listBanks(allBANKS);
> }
>
> function listBanks(allBANKS){
> console.log("Write out just the banks"+allBANKS);
> Abank = allBANKS.split("[");
> Abank.shift();
> for(i=0;i<Abank.length;i++){
> //alert(Abank[i]);
> getBankName(i);
> }
> //alert(bankName);
> bankOptionList();
> defaultBank=1;
> document.getElementById("selBank").selectedIndex = defaultBank;
> ListBankInstruments(defaultBank);
> }
>
> function getBankName(i){
> var ENDBANKNAME = Abank[i].indexOf("]",0);
> bankName[i]=Abank[i].substring(0,ENDBANKNAME);
> }
>
> function ListBankInstruments(current){
> //REMOVE EMPTY LINES FROM BANK
> Abank[current]=Abank[current].replace(/^\s*[\r]/gm,"");
> //SPLIT BANK INTO ARRAY OF INSTRUMENTS
> instName=Abank[current].split("\n");
> //REMOVE FIRST LINE "BANKNAME"
> instName.shift();
> //alert(instName);
> instOptionList();
> }
>
> function bankSelection(){
> current=document.getElementById("selBank").selectedIndex;
> ListBankInstruments(current);
> }
For anyone interested in howto send a bankchange message via the midiApi it is a three part message, two controller messages followed by a program message *necessary*. This is the messages for my Korg N364 unfortunately the banks divided into combis and instruments and i do now know the message to send to change between the two bankmodes.
[toc] | [prev] | [next] | [standalone]
| From | Jonas Thörnvall <jonas.thornvall@gmail.com> |
|---|---|
| Date | 2019-06-01 07:05 -0700 |
| Message-ID | <54488903-40d6-44e5-99bf-aaeb3b4b250a@googlegroups.com> |
| In reply to | #36728 |
Den lördag 1 juni 2019 kl. 16:05:03 UTC+2 skrev Jonas Thörnvall:
> Den onsdag 29 maj 2019 kl. 15:43:26 UTC+2 skrev Jonas Thörnvall:
> > Well i skipped creating any object probably for the better, it reads in bank names in arrays and list array in the bank option list. The same with respective instruments in bank.
> >
> > And at change read in the instrument for bank in question into the option list for the bank selected, just by split the string iont array "and tweaking empty lines not perfect". Simple is better.... or....
> >
> > Yeah i know it will do it everytime.... Well that had only been once with an object but added complexity, that i am not the man to handle. I also fixed so one can read in other instrument files but "my KORG N364" is default.
> >
> > Now it is just to send the message for bank chosen to synth, depending on selection.
> >
> > function splitInstrumentFile(ATXT){
> > bankName=[];
> > var PatchStart = ATXT.indexOf(".Patch Names",0);
> > var NoteStart = ATXT.indexOf(".Note Names",0);
> > var allBANKS=ATXT.substring(PatchStart+12,NoteStart);
> > listBanks(allBANKS);
> > }
> >
> > function listBanks(allBANKS){
> > console.log("Write out just the banks"+allBANKS);
> > Abank = allBANKS.split("[");
> > Abank.shift();
> > for(i=0;i<Abank.length;i++){
> > //alert(Abank[i]);
> > getBankName(i);
> > }
> > //alert(bankName);
> > bankOptionList();
> > defaultBank=1;
> > document.getElementById("selBank").selectedIndex = defaultBank;
> > ListBankInstruments(defaultBank);
> > }
> >
> > function getBankName(i){
> > var ENDBANKNAME = Abank[i].indexOf("]",0);
> > bankName[i]=Abank[i].substring(0,ENDBANKNAME);
> > }
> >
> > function ListBankInstruments(current){
> > //REMOVE EMPTY LINES FROM BANK
> > Abank[current]=Abank[current].replace(/^\s*[\r]/gm,"");
> > //SPLIT BANK INTO ARRAY OF INSTRUMENTS
> > instName=Abank[current].split("\n");
> > //REMOVE FIRST LINE "BANKNAME"
> > instName.shift();
> > //alert(instName);
> > instOptionList();
> > }
> >
> > function bankSelection(){
> > current=document.getElementById("selBank").selectedIndex;
> > ListBankInstruments(current);
> > }
>
> For anyone interested in howto send a bankchange message via the midiApi it is a three part message, two controller messages followed by a program message *necessary*. This is the messages for my Korg N364 unfortunately the banks divided into combis and instruments and i do now know the message to send to change between the two bankmodes.
Oops forgot the code!
function sendBank(){
bankNr=document.getElementById("selBank").selectedIndex;
alert("bankNr="+bankNr);
settingChange = [176,0,0];
outportarr[outportindex].send(settingChange);
settingChange = [176,32,bankNr];
outportarr[outportindex].send(settingChange);
settingChange = [192,0];
outportarr[outportindex].send(settingChange);
}
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.javascript
csiph-web