Jump to content

Phatline

Members
  • Posts

    1,281
  • Joined

  • Last visited

  • Days Won

    71

Posts posted by Phatline

  1. thx has worked:

    FILE_ReadBuffer((u8  *)Sequence[track],  sizeof(Sequence[track]));  //u8 Sequence[8][512][8] 

    FILE_WriteBuffer((u8  *)Sequence[track],  sizeof(Sequence[track]));    //u8 Sequence[8][512][8]

    call: SD(track, clip, job);

    for example: SD(6,1,2); //track 6 dont matter, ProgramChange 1, Load all Clips

                           SD(0,7,1);//track 0, ProgramChange 7, Load single Clip (clip 7-0.sq)

                          SD(0,1,3);//track 0 , ProgramChange 1, Store single Clip (clip 1-0.sq)

                          SD(2,1,4);//track 2 dont matter, ProgramChange 1, Store all Clips

                           SD(2,1,5);//track 2 dont matter, ProgramChange 1 dont matter, Copy track 0-0.sq 512x8 times on SD-Card = Make filestructure = initalize SD-Card > take 20 Minutes

    full code: http://wiki.midibox.org/lib/exe/fetch.php?media=phatline:seq-melody-footboard.zip

    relativly stripped down the SD-Management is done by:

      u8 clip_is_virgin = 1; 
     u16 BPM = 120;
      u8  Rythm = 4;      
      u8 SetDecayTime[8] = {60,60,60,60, 60,60,60,60}; us
      u8 Loop_Length[8] = {1,4,1,4, 1,4,1,4}; 
      u8 CC_SD[8][32] = {}; //Save all other Variables into this Array - for SD-Card...
    
      u8 CC_MSQ[8][512] = {};
      u8 Sequence[8][512][8]={{{}}};     
    
    
    xSemaphoreHandle xSDCardSemaphore; 	// take and give access to SD-Card
    xSemaphoreHandle xLCDSemaphore;		// take and give access to LCD
    
    static file_t midifile_fi; //used to read files from SD-Card
    
    #define MUTEX_LCD_TAKE { while( xSemaphoreTakeRecursive(xLCDSemaphore, (portTickType)0) != pdTRUE ); }  //a Mutex reserve LCD/SD for a task, until it is given away...
    #define MUTEX_LCD_GIVE { xSemaphoreGiveRecursive(xLCDSemaphore); }
    #define PRIORITY_SD                 ( tskIDLE_PRIORITY + 3 ) //3:Mios standart
    
    static void SD(u8 track, u16 clip, u16 job);
    
    void APP_Init(void){
      xLCDSemaphore = xSemaphoreCreateRecursiveMutex(); // create Mutex for LCD access
      xSDCardSemaphore 	= xSemaphoreCreateRecursiveMutex();	//create Mutex for SD-Card access
      FILE_Init(0);// initialize file functions  
    }
    void APP_Tick(void){ //@1mS rate
            SDCardCount++;   //CHECK SD-Car every 2sec.
            if(SDCardCount > 2000) { SDCardCount = 0; SD(0, 0, 5); } //2s Counter > send Check-SDCard-Commant to StoreLoad-Function (u8 track, u16 clip, u16 job)
    }  
    // S T O R A G E - SD - C A R D      ///  read write clips/programchanges
    static void SD(u8 track, u16 clip, u16 job){         //Job1=load all, Job2=store all, Job3=initalize card
        u8 t = 0; //track counter initation
        
        switch(job) {   
    
    // R E A D /////////////////////////////////////////////////////////////////////////////////////////////////////// 
              
                case 1: //LOAD single Clip
                            MUTEX_SDCARD_TAKE;  
                                   sprintf(filepathL, "sq/%d-%d.sq", track, clip);
                                   FILE_ReadOpen  (&midifile_fi, filepathL);
                                   FILE_ReadBuffer((u8  *)file_typeBank,        4); 	
                                   FILE_ReadBuffer((u8  *)CC_SD   [track],  sizeof(CC_SD    [track]));
                                   FILE_ReadBuffer((u8  *)CC_MSQ  [track],  sizeof(CC_MSQ   [track])); //Control-Change-Motion-Sequence
                                   FILE_ReadBuffer((u8  *)Sequence[track],  sizeof(Sequence [track])); //u8 Sequence[8][512][8]  
                                   FILE_ReadBuffer((u8  *)PB      [track],  sizeof(PB       [track]));                  
                                   FILE_ReadClose	(&midifile_fi);
                            MUTEX_SDCARD_GIVE;      
                                
                            //Paste  Variables from Array           
                            Rythm               = CC_SD[track][1];
                            Loop_Length[track]  = CC_SD[track][2];
                            BPM                 = CC_SD[track][4];
                            SetDecayTime[track] = CC_SD[track][5];
                            
                            //Calculate new Loop Lengths
                            Loop[track]         = Loop_Length[track] * MainLoop;
                            
        
                            //SEQ_BPM_Set(BPM);
                            NeedSync = 1; //update ClockCounter when ready...
                   
                            SongNrStor = SongNrLoad; //transfair load nr 2 store nr.
                        break;
                        
                case 2: //LOAD all Clips - FOR  P R O G R A M  C H A N G E
                              for( t=0; t<8; t++) { 
                                    MUTEX_SDCARD_TAKE;  
                                           sprintf(filepathL, "sq/%d-%d.sq", t, clip);
                                           FILE_ReadOpen  (&midifile_fi, filepathL);
                                           FILE_ReadBuffer((u8  *)file_typeBank,     4); 	
                                           FILE_ReadBuffer((u8  *)CC_SD   [t],  sizeof(  CC_SD [t]));
                                           FILE_ReadBuffer((u8  *)CC_MSQ  [t],  sizeof(  CC_MSQ[t])); //Control-Change-Motion-Sequence
                                           FILE_ReadBuffer((u8  *)Sequence[t],  sizeof(Sequence[t])); //u8 Sequence[8][512][8]  
                                           FILE_ReadBuffer((u8  *)PB      [t],  sizeof(      PB[t]));                  
                                           FILE_ReadClose	(&midifile_fi);
                                    MUTEX_SDCARD_GIVE;     
                                     
                                    //Paste  Variables from Array           
                                    Rythm               = CC_SD[t][1];
                                    Loop_Length[t]      = CC_SD[t][2];
                                    BPM                 = CC_SD[t][4];
                                    SetDecayTime[t]     = CC_SD[t][5];
                                    
                                    //Calculate new Loop Lengths
                                    Loop[t]         = Loop_Length[t] * MainLoop;
                            }
                                
    
    
                            //SEQ_BPM_Set(BPM);
                            NeedSync = 1; //update ClockCounter when ready...
                   
                            SongNrStor = SongNrLoad; //transfair load nr 2 store nr.
                            
                            MUTEX_LCD_TAKE; 
                                MIOS32_LCD_DeviceSet(2); MIOS32_LCD_Clear(); MIOS32_LCD_CursorSet(0, 0); 
                                MIOS32_LCD_PrintFormattedString	("%s", "PROGRAM LOAD - Finished");
                            MUTEX_LCD_GIVE; 
                            Update_LCD_s = 1; //normal LCD-Labeling in back again in a second
                        break;
                    	
                        
    // S T O R E /////////////////////////////////////////////////////////////////////////////////////////////////////               
      
                case 3: //S T O R E Single Clip
                
                        //Fill CC-Array of Clip                
                        CC_SD[track][0] = clip_is_virgin;
                        CC_SD[track][1] = Rythm;
                        CC_SD[track][2] = Loop_Length[track];
                        CC_SD[track][4] = BPM;
                        CC_SD[track][5] = SetDecayTime[track];
                
                                    MUTEX_SDCARD_TAKE;
                                            //Write to File
                                            sprintf(filepathS, "sq/%d-%d.sq", track, clip);             
                                            FILE_WriteOpen	(filepathS,                    1);               
                                            FILE_WriteBuffer((u8  *)file_typeBank,         4); //"SQ01" = 4 Positons      
                                            FILE_WriteBuffer((u8  *)CC_SD   [track],  sizeof(CC_SD   [track])); //Track Variables like Looplenght 
                                            FILE_WriteBuffer((u8  *)CC_MSQ  [track],  sizeof(CC_MSQ  [track])); //Control-Change-Motion-Sequence
                                            FILE_WriteBuffer((u8  *)Sequence[track],  sizeof(Sequence[track])); //u8 Sequence[8][512][8]  
                                            FILE_WriteBuffer((u8  *)PB      [track],  sizeof(PB      [track]));  
                                            FILE_WriteClose	(); 
                                    MUTEX_SDCARD_GIVE;  //SD-Card is now free 4 access
                                    Update_LCD_s = 1; //normal LCD-Labeling in back again in secunds
                                    
                                    SongNrLoad = SongNrStor; //transfair load nr 2 store nr.
                        break;
                                    
                case 4: //S T O R E all Clips - FOR  P R O G R A M  C H A N G E
                        
                            for( t=0; t<8; t++)     { // store file once  by once
                                    //Fill CC-Array of Clip                
                                    CC_SD[t][0] = clip_is_virgin;
                                    CC_SD[t][1] = Rythm;
                                    CC_SD[t][2] = Loop_Length[t];           
                                    CC_SD[t][4] = BPM;
                                    CC_SD[t][5] = SetDecayTime[t];
                                    
                                    MUTEX_SDCARD_TAKE;
                                            //Write to File
                                            sprintf(filepathS, "sq/%d-%d.sq", t, clip);             
                                            FILE_WriteOpen	(filepathS,                1);               
                                            FILE_WriteBuffer((u8  *)file_typeBank,     4);  //"SQ01" = 4 Positons      
                                            FILE_WriteBuffer((u8  *)CC_SD   [t],  sizeof(CC_SD   [t]));  //Track Variables like Looplenght 
                                            FILE_WriteBuffer((u8  *)CC_MSQ  [t],  sizeof(CC_MSQ  [t]));   //Control-Change-Motion-Sequence
                                            FILE_WriteBuffer((u8  *)Sequence[t],  sizeof(Sequence[t])); //u8 Sequence[8][512][8]  
                                            FILE_WriteBuffer((u8  *)PB      [t],  sizeof(PB      [t])); 
                                            FILE_WriteClose	(); 
                                    MUTEX_SDCARD_GIVE;  //SD-Card is now free 4 access
                                    }
                                    
                            SongNrLoad = SongNrStor; //transfair load nr 2 store nr.
                            
                            MUTEX_LCD_TAKE; 
                                MIOS32_LCD_DeviceSet(2); MIOS32_LCD_Clear(); MIOS32_LCD_CursorSet(0, 0); 
                                MIOS32_LCD_PrintFormattedString	("%s", "PROGRAM STORE - Finished");
                            MUTEX_LCD_GIVE;
                            Update_LCD_s = 1; //normal LCD-Labeling in back again in secunds
                                                           
                        break;
          
             
    
    //  I N I T - S D - CARD //////////////////////////////////////////////////////////////////////////////////7//////   
      
                case 5: //SD-Card Initalize
                        MUTEX_SDCARD_TAKE;					//SD-Card is now only for the following LINES reserved:
                          statusSD = FILE_CheckSDCard();
                          switch(statusSD) {
                              case 2: MUTEX_LCD_TAKE;  MIOS32_LCD_DeviceSet(2); MIOS32_LCD_Clear(); MIOS32_LCD_CursorSet(0, 0); MIOS32_LCD_PrintFormattedString	("%s", "NO SD-Card"); MUTEX_LCD_GIVE;  break; 
                              case 3:
                                 if	(!FILE_SDCardAvailable() ) {MUTEX_LCD_TAKE; MIOS32_LCD_DeviceSet(2); MIOS32_LCD_Clear(); MIOS32_LCD_CursorSet(0, 0); MIOS32_LCD_PrintFormattedString	("%s", "Insert-FAT-Formated-SD-Card"); MUTEX_LCD_GIVE; break;} 
                                 if	(!FILE_VolumeAvailable() ) {MUTEX_LCD_TAKE; MIOS32_LCD_DeviceSet(2); MIOS32_LCD_Clear(); MIOS32_LCD_CursorSet(0, 0); MIOS32_LCD_PrintFormattedString	("%s", "Format SD-Format to FAT first!"); MUTEX_LCD_GIVE; break;} break;
                              case 1: // YES CARD!  >>> next: check Card-content
                                 statusDir = FILE_DirExists("sq");																								//ask file.c: exist a folder "t/" on the CARD?
                                 if(statusDir == 1){MUTEX_LCD_TAKE; MIOS32_LCD_DeviceSet(2); MIOS32_LCD_Clear(); MIOS32_LCD_CursorSet(0, 0); MIOS32_LCD_PrintFormattedString	("%s", "good SD-file structure");MenueUpdateFlag = 0;MUTEX_LCD_GIVE; break;} 
                                 
                                 if(statusDir == 0){MUTEX_LCD_TAKE; MIOS32_LCD_DeviceSet(2); MIOS32_LCD_Clear(); MIOS32_LCD_CursorSet(0, 0); MIOS32_LCD_PrintFormattedString	("%s", "create 4096 Files on SDC it takes 20min - really!-wait!!! ");MUTEX_LCD_GIVE;
                                                               
                                            //Fill CC-Array of Clip                
                                            CC_SD[track][0] = clip_is_virgin;
                                            CC_SD[track][1] = Rythm;
                                            CC_SD[track][2] = Loop_Length[track];
                                            CC_SD[track][4] = BPM;
                                            CC_SD[track][5] = SetDecayTime[track]; 
                                    
                                            FILE_MakeDir("sq");                           
    
                                            //Write to File
                                            sprintf(filepathS, "sq/%d-%d.sq", track, clip);             
                                            FILE_WriteOpen	(filepathS,                     1);               
                                            FILE_WriteBuffer((u8  *)file_typeBank,          4); //"SQ01" = 4 Positons      
                                            FILE_WriteBuffer((u8  *)CC_SD[track],          32); //Track Variables like Looplenght 
                                            FILE_WriteBuffer((u8  *)CC_MSQ[track],    sizeof(CC_MSQ[track]));   //Control-Change-Motion-Sequence
                                            FILE_WriteBuffer((u8  *)Sequence[track],  sizeof(Sequence[track])); //u8 Sequence[8][512][8]  
                                            FILE_WriteBuffer((u8  *)PB[track],        sizeof(PB[track])); 
                                            FILE_WriteClose	(); 
                                                                
                                                //copy-prototype file to 512x8 clip files on SD-Card
                                                for(t=0; t<8; t++){ 
                                                    
                                                    s16 clipcount = 0; //declare and set the Bank Counter inital value to 0 
                                                    for(clipcount=0; clipcount<512; clipcount++){  //countes 2 511 and do following commandos 511 times in a loop:
                                                        char copyfilepath[16];
                                                        sprintf(copyfilepath, "sq/%d-%d.sq", t, clipcount); //make a new filename depending on the counter value 1.sq, 2.sq, 3.sq...511.sq
                                                        FILE_Copy ((char *)"sq/0-0.sq", (char *)copyfilepath);} //copy the File 0.tm to all other 511 files...
                                                }
                                            
                                    
                                                                        //SD-Card is now free 4 apbess
                            MUTEX_LCD_TAKE; MIOS32_LCD_DeviceSet(0); MIOS32_LCD_Clear(); MIOS32_LCD_CursorSet(0, 0); MIOS32_LCD_PrintFormattedString	("%s", "SD-CARD - INIT - FINISHED"); MUTEX_LCD_GIVE;MenueUpdateFlag = 0;} break;
                            }
                            MUTEX_SDCARD_GIVE;	
                            }
    }

    maybe that helps anyone, or me in the future...

  2. 15 hours ago, Antichambre said:

    Try:

    
    // write
    FILE_WriteBuffer((u8 *)PB[track], sizeof(PB[track]);
    // read
    FILE_ReadBuffer((u8 *)PB[track], sizeof(PB[track]);

    I did it and your project was compiled without error...

    should it does it the same? incl(track) (step) cant wait to try it at home.many thx.4that. mike.

    14 hours ago, Antichambre said:
    
    //write
    u8 PB8[STEP_NUM*2];
    for (i=0; i<STEP_NUM; i++){
      PB8[i*2] = (u8)(PB[track][i] & 0xff);
      PB8[i*2+1] = (u8)(PB[track][i] >> 8);
    }
    FILE_WriteBuffer((u8 *)PB8 , sizeof(PB8));
    //read
    u8 PB8[STEP_NUM*2];
    FILE_ReadBuffer((u8 *)PB8 , sizeof(PB8));
    for (i=0; i<STEP_NUM; i++){
      PB[track][i] = (u16)((PB8[i*2+1] << 8) + PB8[i*2]);
    }

    much less beautiful

     

  3. how ever the endgoal is:

    128 Program-Change/Songs a 4clips = 512clips

    8tracks a 512 clips

    fileformat: [track]-[clip].sq   >>> each clip is a single file which can be called

     

    when i Programchange, it loads the first row of clips >>> clip = PC*4 >>>

    to load a other clip i need to built a 8x8 blm first: the plan is:

    ----------------tr0 tr1 tr2 tr3 tr4 tr5 tr6 tr7

    last PC                                                x       -       Play-Clip from last Song

    empty grid   x    x   x    x    x   x    x   x       -       Indicate that there is no Song to choose

    clip.row0      x    x               x                     -         Play Clips[tr0][cliprow0] of actual song....

    clip.row1                 x                                 -         

    clip.row2                      x

    clip.row3                                     

    empty grid   x    x   x    x    x   x    x   x

    next PC                                         x             -   Play Clips from next song....

     

    so its a bit of ableton like... but more song structured.

  4. On 13.12.2017 at 5:57 PM, Antichambre said:

    What is the calling procedure? can you send me (PM) the project? I need a bigger view.
    I think structure can resolve write and read but I need to know how it is called.
    I'm not at home, nothing to do in the night in my hotel room, I can write something even if I haven't got any hardware to test it...

    Best

    file is up to date in wiki: http://www.midibox.org/dokuwiki/lib/exe/fetch.php?media=phatline:seq-melody-footboard.zip

    when cleaned up this are the Functions involved >

    1.APP_DIN_NotifyToggle >>> set a Flag to 1 (Hi)

    2.TASK_Blink_Decay >>> wait 250ms, then send a Call to: SD(SaveNextFlag, SongNrStor, 2) = TRACK0, Song-PC0, store command

    3.SD(u8 track, u16 clip, u16 job) >>> writing, reading, or initalizing files...

    // local prototype of the task function
    static void TASK_Blink_Decay(void *pvParameters);
    static void SD(u8 track, u16 clip, u16 job);
    
    void APP_DIN_NotifyToggle(u32 pin, u32 pin_value){ //1.STORE-LOAD-BUTTON-ACTION
        if(pin_value == 0) {
            switch(pin) {                 
                case 6:     StoreFlag = 1; break;        
                case 14:    LoadFlag  = 1;  break;         
    }}}   
    
    
    static void SD(u8 track, u16 clip, u16 job){         //3.Job1=load all, Job2=store all, Job3=initalize card
        
    	//STORE
        if(job == 2) {
                        //Fill CC-Array of Clip                
                        CC_SD[0] = clip_is_virgin;
                        CC_SD[1] = Rythm;
                        CC_SD[2] = Loop_Length[track];
                        CC_SD[3] = BPM;
                        CC_SD[4] = SetDecayTime[track]; 
                        
                                           
                        MUTEX_SDCARD_TAKE;
                            //Write to File
                            sprintf(filepathS, "sq/%d-%d.sq", track, clip);             
                                        FILE_WriteOpen	(filepathS,                        1);               
                                        FILE_WriteBuffer((u8  *)file_typeBank,             4); //"SQ01" = 4 Positons      
                                        FILE_WriteBuffer((u8  *)CC_SD,                    32); //Track Variables like Looplenght                      
                                        FILE_WriteBuffer((u8  *)Sequence[track],        2048); //u8 Sequence[8][256][8]={{{}}};     //8Tracks, 256Steps, 8NotePolyphony
                                        
                                        for(i=0; i<256; i++)FILE_WriteHWord (PB[track][i]); //write Pitchbend u16 values directly 
                                        FILE_WriteClose	(); 
                        MUTEX_SDCARD_GIVE;  //SD-Card is now free 4 apbess
                        
                        SongNrLoad = SongNrStor; //transfair load nr 2 store nr.
                        SD_Done_StoreFlag = 1;}
        
            
            
            
        //LOAD
        if(job == 1) {//Load all Data- whole Program-Change-Patterns
    
                            MUTEX_SDCARD_TAKE;  
                                //NOTE-Data of Clip
                               sprintf(filepathL, "sq/%d-%d.sq", track, clip);
                               FILE_ReadOpen  (&midifile_fi, filepathL);
                               FILE_ReadBuffer((u8  *)file_typeBank,        4); 	
                               FILE_ReadBuffer((u8  *)CC_SD,               32); 
                               FILE_ReadBuffer((u8  *)Sequence[track],   2048); //u8 Sequence[8][256][8]                 
                               for(i=0; i<256; i++)FILE_ReadHWord (&PB[track][i]); //read Pitchbend u16 values directly                  
                               FILE_ReadClose	(&midifile_fi);
                             MUTEX_SDCARD_GIVE;      
                            
                                //Paste  Variables from Array           
                                clip_is_virgin      = CC_SD[0];
                                Rythm               = CC_SD[1];
                                Loop_Length[track]  = CC_SD[2];
                                BPM                 = CC_SD[3];
                                SetDecayTime[track] = CC_SD[4];
    
    
                               //SEQ_BPM_Set(BPM);
               NeedSync = 1; //update ClockCounter when ready...
               
               SongNrStor = SongNrLoad; //transfair load nr 2 store nr.
               SD_Done_Load_Flag = 1;}
        
        
        //SD-Card Initalize - Files
      if((job == 3) && (clip < 8)){//CHECK SD-Card/Initalize Card
    ....
    ....                                      
    }//End While
    }//End TICK 0 >>> 1ms Task...

     

  5. 7 hours ago, Antichambre said:

    How do you init PB as aray of int or pointer?
    If array of int:

    
    for(i=0; i<256; i++)FILE_WriteHWord (PB[track][i]); //write Pitchbend u16 values directly    
    for(i=0; i<256; i++)FILE_ReadHWord (&PB[track][i]); //read Pitchbend u16 values directly    

     

        u16 PB[8][256] = {{}};

    dont working, LCD hangs.... by just sending a ... SD(0,0,2 or 1) .... i decoppelt already the Load/Store button to directly act on the SD-Function (with counters in milliseconds) which solved issues but not the pitchbend thing...

    static void SD(u8 track, u16 clip, u16 job){ 
        
    	//STORE
        if(job == 2) {             
                        MUTEX_SDCARD_TAKE;
                            //Write to File
                            sprintf(filepathS, "sq/%d-%d.sq", track, clip);             
                                        FILE_WriteOpen	(filepathS,                        1);               
                                        FILE_WriteBuffer((u8  *)file_typeBank,             4); //"SQ01" = 4 Positons      
                                        FILE_WriteBuffer((u8  *)CC_SD,                    32); //Track Variables like Looplenght                      
                                        FILE_WriteBuffer((u8  *)Sequence[track],        2048); //u8 Sequence[8][256][8]={{{}}};     /
    
                                        for(i=0; i<256; i++)FILE_WriteHWord (PB[track][i]); //write Pitchbend u16 values directly 
                                        FILE_WriteClose	(); 
                        MUTEX_SDCARD_GIVE;  //SD-Card is now free
                        
                        SD_Done_StoreFlag = 1;}
    
                                                        
        //LOAD
        if(job == 1) {
                            MUTEX_SDCARD_TAKE;  
                                //READ FILE
                               sprintf(filepathL, "sq/%d-%d.sq", track, clip);
                               FILE_ReadOpen  (&midifile_fi, filepathL);
                               FILE_ReadBuffer((u8  *)file_typeBank,        4); 	
                               FILE_ReadBuffer((u8  *)CC_SD,               32); 
                               FILE_ReadBuffer((u8  *)Sequence[track],   2048); //u8 Sequence[8][256][8]             
                                                        
                               for(i=0; i<256; i++)FILE_ReadHWord (&PB[track][i]); //read Pitchbend u16 values directly                  
                               FILE_ReadClose	(&midifile_fi);
                             MUTEX_SDCARD_GIVE;      
        
               SD_Done_Load_Flag = 1;}

     

  6. this line stops my lcd from reacting and nothing will be written:

    
                               for(i=0; i<256; i++){ //16bit  pitchbend to 2x8bit -saveable with Writebuffer
                                                  PB8[0][i] = PB[track][i] & 0xff;
                                                  PB8[1][i] = PB[track][i] >> 8;}  
                                                   

     

    when used in:

     

                            for (track=0; track<8; track++){ //count thru all tracks
    
                               for(i=0; i<256; i++){ //16bit  pitchbend to 2x8bit -saveable with Writebuffer
                                                  PB8[0][i] = PB[track][i] & 0xff;
                                                  PB8[1][i] = PB[track][i] >> 8;}  
                                                   
                                MUTEX_SDCARD_TAKE;
                                    //Write to File
                                    sprintf(filepathS, "sq/%d-%d.sq", track, SongNrStor*4);             
                                                FILE_WriteOpen	(filepathS,                        1);               
                                                FILE_WriteBuffer((u8  *)file_typeBank,             4); //"SQ01" = 4 Positons      
                                                FILE_WriteBuffer((u8  *)CC_SD,                    32); //Track Variables like Looplenght                      
                                                FILE_WriteBuffer((u8  *)Sequence[track],        2048); //u8 Sequence[8][256][8]
                                                FILE_WriteBuffer((u8  *)PB8,                     512); //2x256
                                                FILE_WriteClose	(); 
                                MUTEX_SDCARD_GIVE;  //SD-Card is now free 4 apbess
                        }

    , if i delete this lines: all files are written/loadet fine, 

    maybe the bitshift takes to long... or sd access is to slow... or code is just waste...

  7. 4 hours ago, Antichambre said:

    You can try to write your 256 16bit values directly.

    
    #define STEP_NUM 256
    u16 PB[STEP_NUM];
    //populate PB
    //...
    //write PB
    for(i=0; i<STEP_NUM ; i++)FILE_WriteHWord(PB[i]); 

     

    hm having troubles by Reading the HWORD - compiler error:

    make (im Verzeichnis: /home/...)
    rm -f project.hex
    Creating object file for app.c
    app.c: In function 'SD':
    app.c:857:40: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
    -------------------------------------------------------------------------------
    Application successfully built for:....

    app.c:857:40 isthis line:

      for(i=0; i<256; i++){FILE_ReadHWord ((u16  *)PB[track][i]);}  //read Pitchbend u16 values directly    ??

     

    u16* and u16

    by using this code

    //STORE
        if((job == 2) && (track == 8)) {//Store all Data- whole Program-Change-Patterns            
                            MUTEX_SDCARD_TAKE;
                            for (track=0; track<8; track++){ //count thru all tracks
                                                   
                        //Write to File
                        sprintf(filepathS, "sq/%d-%d.sq", track, clip);             
                                        FILE_WriteOpen	(filepathS,                     1);               
                                        FILE_WriteBuffer((u8  *)file_typeBank,          4); //"SQ01" = 4 Positons      
                                        FILE_WriteBuffer((u8  *)CC_SD,                 32); //Track Variables like Looplenght                      
                                        FILE_WriteBuffer((u8  *)Sequence[track],     2048); //8Tracks, 256Steps, 8NotePolyphony
                   for(i=0; i<256; i++){FILE_WriteHWord(PB[track][i]);}  //write Pitchbend u16 values directly
                                        //FILE_WriteBuffer((u8  *)PB8,                 1024); //2x8Bit Pitchbendvalue...2 x 512 Steps= 1024 Blocks                               
                                        FILE_WriteClose	();                         
                        }        
                         MUTEX_SDCARD_GIVE;     
            }
            
        //LOAD
        if((job == 1) && (track == 8)) {//Load all Data- whole Program-Change-Patterns
                      MUTEX_SDCARD_TAKE;     
                        for (track=0; track<8; track++){ 
                            //NOTE-Data of Clip
                           sprintf(filepathL, "sq/%d-%d.sq", track, clip);
                           FILE_ReadOpen  (&midifile_fi, filepathL);
                           FILE_ReadBuffer((u8  *)file_typeBank,       4); 	
                           FILE_ReadBuffer((u8  *)CC_SD,              32); // ALL OTHER VARIABLES are saved in this ARRAY (CC_SD[128])  
                           FILE_ReadBuffer((u8  *)Sequence[track],  2048); ////8Tracks, 256Steps, 8NotePolyphony             
                           u16 i = 0;
      for(i=0; i<256; i++){FILE_ReadHWord ((u16  *)PB[track][i]);}  //write Pitchbend u16 values directly                                    
                           FILE_ReadClose	(&midifile_fi); 
    
                } 
                MUTEX_SDCARD_GIVE;
            }
        }

     

  8. hi

    save my patches with FILE_WriteBuffer like this:

                // 16Bit Pitchbend-value to 2x8Bit value - to get a saveable format
                PB8[0] = * ((unsigned char *)&PB[track]);       //low byte
                PB8[1] = * ((unsigned char *)((&PB[track])+1)); //hi byte
                     
                //Fill CC-Array of Clip                
                CC_SD[0] = clip_is_virgin;
                CC_SD[1] = Rythm;
                CC_SD[2] = Loop_Length[track];
                CC_SD[3] = BPM;
                CC_SD[4] = SetDecayTime[track];   
                                  
                //Note-Data of Clip
                sprintf(filepathS, "sq/%d-%d.sq", track, clip);             //First Pattern --- will be later copied 511 times! 	sq/8-512.pb
                                FILE_WriteOpen	(filepathS,                     1);               
                                FILE_WriteBuffer((u8  *)file_typeBank,          4); //"SQ01" = 4 Positons      
                                FILE_WriteBuffer((u8  *)CC_SD,                 32); //Track Variables like Looplenght 
                                FILE_WriteBuffer((u8  *)PB8,                  512); //2x8Bit Pitchbendvalue x 256 Steps     = 512 Blocks                        
                                FILE_WriteBuffer((u8  *)Sequence[track],     2048); //Track, 256Steps, 8NotePolyphony 1x256x8 = 2048 Blocks
                                FILE_WriteClose	();                        
                         

     

    i want to save the Pitchband also, i but this is 16bit, and that cant be Written, i need 8Bit Values, so my my 16Bit Pitchband-Variable is named PB[track]

    it is done by:

                // 16Bit Pitchbend-value to 2x8Bit value - to get a saveable format
                PB8[0] = * ((unsigned char *)&PB[track]);       //low byte
                PB8[1] = * ((unsigned char *)((&PB[track])+1)); //hi byte

    so far ok, QUESTION is: how to combine low and hi byte back to the 16bit Variable PB[track]? (after FILE_ReadBuffer is done)

    next question is how to split a multiy-array in low and hi bytes variables: for example PB[track][256]    --- which is the Pitchbend-Information - over 256 Steps in a Sequence.

     

     thx 4 helpß

  9. On 7.12.2017 at 0:07 PM, zener said:

    ..

     

    switching / jumping between the 2 "cores" onfly to use for example in live performance , when during the sequencer "core" run the song

     

    good point! its far better the ui is updated directly via srio then via midi sysex  cc or notes.. 32th blinking of 16x2 trigger indicatos bling and blang via midi making trouble...  for example i have connected a sequencer to a blm(acts as controller) but all trigger indicators are leds from the sequencer to give timed indication

     

    isnt there any mb bus? from core to core

  10. On 4.12.2017 at 4:01 PM, zener said:

    After a number of years running up-down-in-out of dozens and dozens and dozens of threads ,

    thousand of posts and hours dedicated / missed  :pout: to get all info and helps necessary to complete a MidiBox Unit (Hui controller ,"NG", Sequencer), 

    at the end for all projects a very extensive knowledge of the C-Code is essential for get a full working unit (unfortunately) :cry:,

    i.m.h.o. MidiBox is a great project because the true "Force" of  this device is the possibility to obtain a customized device controller not available on the market  ,

    (ok so true it require a large number of hours for soldering and assembly (time is money!!! ) + parts cost )

    considered that many used midi-usb controllers can be found today for very low price , seem to really not have logical "sense" start with a MidiBox project ,

    But (as wrote above)  the fact that a customized controller device not available on the market can be obtained with the MidiBox projects

    give to this Device a very strong "force point"   , 

    that said ,

    the "issue" about the  extensive knowledge of the C-Code required is a so big limit / stumbling block for a large number of "potential" users :cry: ,

    that have the sufficient electronic knowledge for assembly/soldering  the hardware required ,

    but not for the software settings/customizations ,

    then the question is :

    There is really not a way to make the "software" project part more "friendly" and simple ?  8-I

     

     

    oh i had the same, thoughts back in the days... not knowing what a external c-function is, and where the hell they are - thats a thing to learn first to get a point how TK arrange things...

    since i learned how to wiki, i also document that - for me to remember - and for other to get some inspiration.

    hmm i see three options:

    * learn how to NG-Script

    * learn no NG-Script - learn C instead + get the compiler running on your Computer

    * ask someone who do the programming for you... but if you want to change something after - you probably have to script or c again.

     

    i personally never learned c in shool or mentor...

    back in the days when max4live come up, i startet with graphical programming (Without c), t

    he programm i created, i later programmed on TK MIOS32, and i learned only the c-things i needet to get the programm running which i already know -via internet youtube and google researching- i was knowing what i need and want...     i cant learn anything that i dont need @ the moment ... i am no expert too, but i make my own devices and jam with my bandmate every week since years...

    a "only musican" should just ask a friend to help him

    a musican which want to use custom or setup a custom midicontroller - have to explore that matter and that take time and entusiasm

     

     

  11. i want to connect one Encoder directly to J5a

    i know that in my Code i have to

    initalize this pins:

      // initialize pin 2 of J5A,  as Digital input with internal Pull-UP //connect to ground
        MIOS32_BOARD_J5_PinInit(0, MIOS32_BOARD_PIN_MODE_INPUT_PU);    
        MIOS32_BOARD_J5_PinInit(1, MIOS32_BOARD_PIN_MODE_INPUT_PU);

    and i also can observe the state of the J5a pin by putting following code into APP_Background:

    MIOS32_BOARD_J5_PinGet(0)
    MIOS32_BOARD_J5_PinGet(1)

    all clear so far, and working good with buttons (with hardware debouncing ):

    debouce-circuit

     

    how does a Encoder-Code look like (without any Acceleration), and how does Hardware debouncing look like (the same like for buttons?), i want to use as less code then possible...

     

    thx 4 any tips

     

  12. is it possible to convert a Midiclock-Stream to audio?

    and convert this audio-recording back to midiclock?

    so i could use one of the RECorder-channels for the midi (clock start stop notes and so on)

    are there already devices out there? i can remember that 30 years ago such things as midi tape exist... or is it maybe a cheap trick that can be solved with an optocopler an opamp and a few lines of code?

    its done

    Clk2aClk-L12-switch-led.thumb.jpg.bef148

    Clk2aClk-L12-rack-inside.thumb.jpg.5df01

    Clk2aClk-L12-rack-back.thumb.jpg.636cc35

    Clk2aClk-L12-rack-solution.thumb.jpg.5a3

    5b08cb32bb579_gehuse-fertig.thumb.jpg.a4clk2a2clk-proto-shematic.thumb.jpg.5002d

     

    VIDEO-Overdubbing a JP8080:

     

     

×
×
  • Create New...