generated from Programming-TRIGON/RobotTemplate
    
        
        - 
                Notifications
    
You must be signed in to change notification settings  - Fork 0
 
Orchestra #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Open
      
      
            ShmayaR
  wants to merge
  48
  commits into
  main
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
orchestra
  
      
      
   
  
    
  
  
  
 
  
      
    base: main
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
  
     Open
                    Orchestra #47
Changes from 12 commits
      Commits
    
    
            Show all changes
          
          
            48 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      836690f
              
                added orchestra stuff
              
              
                ShmayaR 51bd0c6
              
                changed name from TrigonOrchestra to Orchestra
              
              
                ShmayaR ae0cd14
              
                Ugliness so @ShmayaR can clean :)
              
              
                Strflightmight09 38060ab
              
                Hard code 💪
              
              
                Strflightmight09 4f06706
              
                added java docs
              
              
                ShmayaR c6169f9
              
                rewrote java docs
              
              
                ShmayaR 8c7f53a
              
                rewrote java docs again
              
              
                ShmayaR 567a210
              
                Update Orchestra.java
              
              
                ShmayaR 9ae124b
              
                fixed up java doc
              
              
                ShmayaR 52dd814
              
                Update Orchestra.java
              
              
                ShmayaR 4488b3e
              
                Update TalonFXMotor.java
              
              
                ShmayaR b015457
              
                Update Orchestra.java
              
              
                ShmayaR ac91426
              
                shortened a java doc into one @return
              
              
                ShmayaR d6da940
              
                Fix error message
              
              
                Strflightmight09 f621f70
              
                No more throwing
              
              
                Strflightmight09 f44fc18
              
                Merge branch 'main' into orchestra
              
              
                Strflightmight09 3012beb
              
                Quick fix
              
              
                Strflightmight09 5289a52
              
                WOW
              
              
                Strflightmight09 32e3df0
              
                Try this
              
              
                Strflightmight09 9048ec2
              
                ok sure
              
              
                Strflightmight09 cc95c54
              
                tets
              
              
                Strflightmight09 33c5a01
              
                NOw tis goinna work trust
              
              
                Strflightmight09 52c9fe9
              
                I thiikn we got it guys
              
              
                Strflightmight09 4183fa2
              
                A bit of an update
              
              
                Strflightmight09 dba95ee
              
                ID 0 😢
              
              
                Strflightmight09 4b50c8a
              
                Oops
              
              
                Strflightmight09 cf18c47
              
                Fix
              
              
                Strflightmight09 b8b63f6
              
                Test idk
              
              
                Strflightmight09 9e42192
              
                oops
              
              
                Strflightmight09 e5669f2
              
                Optimization
              
              
                Strflightmight09 4dccd5b
              
                test
              
              
                Strflightmight09 ed478c8
              
                more test
              
              
                Strflightmight09 bee510a
              
                Smth idek
              
              
                Strflightmight09 4091b2c
              
                For testing purposes
              
              
                Strflightmight09 5ab2372
              
                test
              
              
                Strflightmight09 533042a
              
                wowow
              
              
                Strflightmight09 4a2c572
              
                ArrayList is goated
              
              
                Strflightmight09 5828631
              
                ?
              
              
                Strflightmight09 06bd78d
              
                Ughhhhh
              
              
                Strflightmight09 8ce853f
              
                O
              
              
                Strflightmight09 f475382
              
                WTHELLYYYYYYYYYYYYY
              
              
                Strflightmight09 0da6572
              
                whatttttttttttt
              
              
                Strflightmight09 b0e0a2c
              
                JIOHSEF"DS
              
              
                Strflightmight09 ee67c54
              
                test ig
              
              
                Strflightmight09 c4a0c2f
              
                Fine
              
              
                Strflightmight09 cead20d
              
                Simplify
              
              
                Strflightmight09 609f645
              
                Small improvement
              
              
                Strflightmight09 f0f5c87
              
                Replay protection and used IDs instead of skipped
              
              
                Strflightmight09 File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,109 @@ | ||
| package org.trigon.utilities; | ||
| 
     | 
||
| import com.ctre.phoenix6.hardware.TalonFX; | ||
| 
     | 
||
| import java.util.ArrayList; | ||
| 
     | 
||
| /** | ||
| * A class that uses the {@link com.ctre.phoenix6.Orchestra} library in Phoenix 6 to play a .chrp file. | ||
| */ | ||
| public class Orchestra { | ||
| private static final com.ctre.phoenix6.Orchestra ORCHESTRA = new com.ctre.phoenix6.Orchestra(); | ||
| private static final ArrayList<TalonFX> MOTORS = new ArrayList<>(); | ||
                
      
                  ShmayaR marked this conversation as resolved.
               
              
                Outdated
          
            Show resolved
            Hide resolved
         | 
||
| 
     | 
||
| /** | ||
| * Adds a motor to the Orchestra. | ||
| * The Orchestra can then play the music from those motors. | ||
| * | ||
| * @param motor the motor to be added to the Orchestra | ||
| */ | ||
| public static void addMotor(TalonFX motor) { | ||
| MOTORS.add(motor); | ||
| } | ||
| 
     | 
||
| /** | ||
| * Plays a .chrp file and assigns a track to each motor. | ||
| * A .chrp file stores music as tracks that can be played separately. | ||
| * The tracks are assigned linearly and loop back if there are extra motors. | ||
| * | ||
| * @param filePath the path of the .chrp file to be played by the Orchestra | ||
| * @param totalTracks the number of tracks in the .chrp file. | ||
| */ | ||
| public static void playFile(String filePath, int totalTracks) { | ||
| for (int i = 0; i < MOTORS.size(); i++) | ||
| ORCHESTRA.addInstrument(MOTORS.get(i), i % totalTracks + 1); | ||
| 
     | 
||
| addAndPlayFile(filePath); | ||
| } | ||
| 
     | 
||
| /** | ||
| * plays a .chrp file and assigns a track to each motor. | ||
| * A .chrp file stores music as tracks that can be played separately. | ||
| * The tracks are assigned by the {@code motorsPerTrack}. | ||
| * Each slot represents a track. | ||
| * Each value in the slot represents the number of motors that will be assigned that track. | ||
| * | ||
| * @param filePath the path of the .chrp file to be added to the Orchestra | ||
| * @param motorsPerTrack number of motors that should be assigned to each track | ||
| */ | ||
| public static void playFile(String filePath, int... motorsPerTrack) throws IllegalStateException { | ||
                
      
                  Strflightmight09 marked this conversation as resolved.
               
              
                Outdated
          
            Show resolved
            Hide resolved
         | 
||
| int totalUsedMotors = 0; | ||
| int motorsAssignedTracks = 0; | ||
| for (int i = 0; i < motorsPerTrack.length; i++) { | ||
| totalUsedMotors += motorsPerTrack[i]; | ||
| if (totalUsedMotors > MOTORS.size()) | ||
| System.out.println("Not enough motors added to the Orchestra."); | ||
                
      
                  Strflightmight09 marked this conversation as resolved.
               
              
                Outdated
          
            Show resolved
            Hide resolved
         | 
||
| for (int j = 0; j < motorsPerTrack[i]; i++) | ||
| ORCHESTRA.addInstrument(MOTORS.get(motorsAssignedTracks++), i + 1); | ||
| } | ||
| addAndPlayFile(filePath); | ||
| } | ||
| 
     | 
||
| /** | ||
| * Stops the music and removes all tracks assigned to motors. | ||
| */ | ||
| public static void stop() { | ||
| ORCHESTRA.stop(); | ||
| ORCHESTRA.clearInstruments(); | ||
                
      
                  Strflightmight09 marked this conversation as resolved.
               
          
            Show resolved
            Hide resolved
         | 
||
| } | ||
| 
     | 
||
| /** | ||
| * Plays the stored .chrp file. | ||
| */ | ||
| public static void play() { | ||
| ORCHESTRA.play(); | ||
| } | ||
| 
     | 
||
| /** | ||
| * Pauses the music. | ||
| */ | ||
| public static void pause() { | ||
| ORCHESTRA.pause(); | ||
| } | ||
| 
     | 
||
| /** | ||
| * @return if music is playing | ||
                
      
                  Strflightmight09 marked this conversation as resolved.
               
              
                Outdated
          
            Show resolved
            Hide resolved
         | 
||
| */ | ||
                
      
                  ShmayaR marked this conversation as resolved.
               
              
                Outdated
          
            Show resolved
            Hide resolved
         | 
||
| public static boolean isOrchestraCurrentlyPlayingMusic() { | ||
| return ORCHESTRA.isPlaying(); | ||
| } | ||
| 
     | 
||
| /** | ||
| * Gets the play time of the .chrp file being played in seconds. | ||
| * | ||
| * @return the play time | ||
| */ | ||
| public static double getPlayTimeSeconds() { | ||
                
      
                  Strflightmight09 marked this conversation as resolved.
               
              
                Outdated
          
            Show resolved
            Hide resolved
         | 
||
| return ORCHESTRA.getCurrentTime(); | ||
| } | ||
                
      
                  ShmayaR marked this conversation as resolved.
               
          
            Show resolved
            Hide resolved
         | 
||
| 
     | 
||
| /** | ||
| * Adds a .chrp file to the Orchestra and plays it. | ||
| * | ||
| * @param filePath the path of the .chrp file to be added to the Orchestra | ||
| */ | ||
| private static void addAndPlayFile(String filePath) { | ||
                
      
                  Strflightmight09 marked this conversation as resolved.
               
          
            Show resolved
            Hide resolved
         | 
||
| ORCHESTRA.loadMusic(filePath); | ||
| play(); | ||
| } | ||
| } | ||
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.