Changeset 1434 for trunk/src/org/apollo


Ignore:
Timestamp:
10/02/19 14:19:48 (5 years ago)
Author:
bln4
Message:

Implementation of ProfileManager. Refactor + additional content for how new profiles are created. The refactoring split out the creation of the default profile from user profiles. Refactoring revealed a long term bug that was causing user profiles to generate with incorrect information. The additional content fixed this bug by introducing the ${USER.NAME} variable, so that the default profile frameset can specify resource locations located in the users resource directory.

org.expeditee.auth.AuthenticatorBrowser
org.expeditee.auth.account.Create
org.expeditee.gui.Browser
org.expeditee.gui.management.ProfileManager
org.expeditee.setting.DirectoryListSetting
org.expeditee.setting.ListSetting
org.expeditee.settings.UserSettings

Implementation of ResourceManager as a core location to get resources from the file system. Also the additional variable ${CURRENT_FRAMESET} to represent the current frameset, so that images can be stored in the directory of the current frameset. This increases portability of framesets.

org.expeditee.gui.FrameIO
org.expeditee.gui.management.ResourceManager
org.expeditee.gui.management.ResourceUtil
Audio:

#NB: Audio used to only operate on a single directory. This has been updated to work in a same way as images. That is: when you ask for a specific resouce, it looks to the user settings to find a sequence of directories to look at in order until it manages to find the desired resource.


There is still need however for a single(ish) source of truth for the .banks and .mastermix file. Therefore these files are now always located in resource-<username>\audio.
org.apollo.agents.MelodySearch
org.apollo.audio.structure.AudioStructureModel
org.apollo.audio.util.MultiTrackPlaybackController
org.apollo.audio.util.SoundDesk
org.apollo.gui.FrameLayoutDaemon
org.apollo.io.AudioPathManager
org.apollo.util.AudioPurger
org.apollo.widgets.FramePlayer
org.apollo.widgets.SampledTrack

Images:

org.expeditee.items.ItemUtils

Frames:

org.expeditee.gui.FrameIO

Fixed a error in the FramePlayer class caused by an incorrect use of toArray().

org.apollo.widgets.FramePlayer


Added several short cut keys to allow for the Play/Pause (Ctrl + P), mute (Ctrl + M) and volume up/down (Ctrl + +/-) when hovering over SampledTrack widgets.

org.apollo.widgets.SampledTrack


Changed the way that Authenticate.login parses the new users profile to be more consistance with other similar places in code.

org.expeditee.auth.account.Authenticate


Encapsulated _body, _surrogateItemsBody and _primaryItemsBody in Frame class. Also changed getBody function to take a boolean flag as to if it should respect the current surrogate mode. If it should then it makes sure that labels have not changed since last time getBody was called.

org.expeditee.gui.Frame

Location:
trunk/src/org/apollo
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/apollo/agents/MelodySearch.java

    r1244 r1434  
    1111
    1212import org.apollo.ApolloSystem;
    13 import org.apollo.io.AudioPathManager;
    1413import org.apollo.meldex.DynamicProgrammingAlgorithm;
    1514import org.apollo.meldex.McNabMongeauSankoffAlgorithm;
     
    2827import org.expeditee.gui.Frame;
    2928import org.expeditee.gui.FrameIO;
    30 import org.expeditee.settings.folders.FolderSettings;
     29import org.expeditee.gui.management.ResourceManager;
    3130import org.expeditee.items.Item;
    3231import org.expeditee.items.ItemUtils;
     
    3433import org.expeditee.items.widgets.WidgetCorner;
    3534import org.expeditee.items.widgets.WidgetEdge;
     35import org.expeditee.settings.folders.FolderSettings;
    3636
    3737/**
     
    278278                                               
    279279                                                // Get cached melody from file if it is up to date
    280                                                 String metaFilePath =
    281                                                         AudioPathManager.AUDIO_HOME_DIRECTORY
    282                                                         + MELODY_METAFILE_PREFIX
    283                                                         + localFilename
    284                                                         + MELODY_METAFILE_SUFFIX;
    285                                                
    286                                                 File localFile = new File(AudioPathManager.AUDIO_HOME_DIRECTORY + localFilename);
     280                                                String metaFileRelativePath = MELODY_METAFILE_PREFIX + localFilename + MELODY_METAFILE_SUFFIX;
     281                                                String metaFilePath = ResourceManager.getAudioResource(metaFileRelativePath, DisplayController.getCurrentFrame()).getAbsolutePath();
     282                                               
     283                                                //File localFile = new File(AudioPathManager.AUDIO_HOME_DIRECTORY + localFilename);
     284                                                File localFile = ResourceManager.getAudioResource(localFilename, DisplayController.getCurrentFrame());
    287285                                                if (!localFile.exists()) continue;
    288286                                               
  • trunk/src/org/apollo/audio/structure/AudioStructureModel.java

    r1244 r1434  
    1616import org.apollo.audio.ApolloSubjectChangedEvent;
    1717import org.apollo.io.AudioIO;
    18 import org.apollo.io.AudioPathManager;
    1918import org.apollo.mvc.AbstractSubject;
    2019import org.apollo.mvc.SubjectChangedEvent;
     
    3029import org.expeditee.gui.Frame;
    3130import org.expeditee.gui.FrameIO;
     31import org.expeditee.gui.management.ResourceManager;
    3232import org.expeditee.io.Conversion;
    3333import org.expeditee.items.ItemUtils;
     
    433433                                try {
    434434                                       
    435                                         tmodel.runningTimeMS = AudioIO.getRunningTime(AudioPathManager.AUDIO_HOME_DIRECTORY + localFilename);
     435                                        String localFilePath = ResourceManager.getAudioResource(localFilename, DisplayController.getCurrentFrame()).getAbsolutePath();
     436                                        tmodel.runningTimeMS = AudioIO.getRunningTime(localFilePath);
    436437                               
    437438                                } catch (IOException e) {
  • trunk/src/org/apollo/audio/util/MultiTrackPlaybackController.java

    r1102 r1434  
    2020import org.apollo.audio.structure.TrackGraphLoopException;
    2121import org.apollo.audio.structure.TrackGraphNode;
    22 import org.apollo.io.AudioPathManager;
    2322import org.apollo.io.AudioIO.AudioFileLoader;
    2423import org.apollo.mvc.AbstractSubject;
     
    3433import org.expeditee.gui.DisplayController;
    3534import org.expeditee.gui.DisplayObserver;
     35import org.expeditee.gui.management.ResourceManager;
    3636
    3737public class MultiTrackPlaybackController
     
    10041004                                               
    10051005                                                try {
     1006                                                        String filepath = ResourceManager.getAudioResource(absNode.getTrackNode().getLocalFilename(), DisplayController.getCurrentFrame()).getAbsolutePath();
    10061007                                                        stm = TrackModelLoadManager.getInstance().load(
    1007                                                                         AudioPathManager.AUDIO_HOME_DIRECTORY + absNode.getTrackNode().getLocalFilename(),
     1008                                                                        filepath,
    10081009                                                                        absNode.getTrackNode().getLocalFilename(),
    10091010                                                                        new Observer() { // opps, my confusing design pattern gone wrong!
  • trunk/src/org/apollo/audio/util/SoundDesk.java

    r375 r1434  
    7171       
    7272        /** Where the mixes are saved to. */
    73         private static final String MIX_BANKS_FILEPATH = AudioPathManager.AUDIO_HOME_DIRECTORY + ".banks";
    74        
    75         private static final String MASTER_MIX_FILEPATH = AudioPathManager.AUDIO_HOME_DIRECTORY + ".mastermix";
     73        private static final String MIX_BANKS_FILEPATH = AudioPathManager.AUDIO_USERNAME_HOME_DIRECTORY + ".banks";
     74       
     75        private static final String MASTER_MIX_FILEPATH = AudioPathManager.AUDIO_USERNAME_HOME_DIRECTORY + ".mastermix";
    7676       
    7777        private static final String NO_SOLO_PREFIX = "~#SOLOOFF#~";
  • trunk/src/org/apollo/gui/FrameLayoutDaemon.java

    r1258 r1434  
    1515import org.apollo.audio.util.Timeline;
    1616import org.apollo.io.AudioIO;
    17 import org.apollo.io.AudioPathManager;
    1817import org.apollo.mvc.AbstractSubject;
    1918import org.apollo.mvc.Observer;
     
    3231import org.expeditee.gui.Frame;
    3332import org.expeditee.gui.FreeItems;
     33import org.expeditee.gui.management.ResourceManager;
    3434import org.expeditee.items.Item;
    3535import org.expeditee.items.ItemUtils;
     
    766766                                // so cann afford to hang the thread a little for checking the actual time...
    767767                                if (runningTime <= 0) {
    768                                         File f = new File(AudioPathManager.AUDIO_HOME_DIRECTORY +
    769                                                         sampledTrackWidget.getLocalFileName());
     768                                        //File f = new File(AudioPathManager.AUDIO_HOME_DIRECTORY +
     769                                        //              sampledTrackWidget.getLocalFileName());
     770                                        File f = ResourceManager.getAudioResource(sampledTrackWidget.getLocalFileName(), DisplayController.getCurrentFrame());
    770771                                        if (f.exists()) {
    771772                                                try {
  • trunk/src/org/apollo/io/AudioPathManager.java

    r1327 r1434  
    77import java.io.IOException;
    88import java.io.UnsupportedEncodingException;
     9import java.util.ArrayList;
     10import java.util.List;
    911import java.util.Random;
     12import java.util.function.Predicate;
    1013
    1114import org.apollo.audio.structure.AudioStructureModel;
    1215import org.apollo.util.ApolloSystemLog;
    1316import org.apollo.util.RegExpFileFilter;
    14 import org.expeditee.auth.AuthenticatorBrowser;
     17import org.expeditee.gui.DisplayController;
    1518import org.expeditee.gui.FrameIO;
     19import org.expeditee.gui.management.ResourceManager;
    1620import org.expeditee.settings.UserSettings;
    1721
     
    2933
    3034        /** Suffixed with the native file separator */
    31         public static String AUDIO_HOME_DIRECTORY = null;
     35        public static String AUDIO_USERNAME_HOME_DIRECTORY = null;
    3236       
    3337        /** Stores all virtual names created by this repository. */
     
    3943
    4044        private static Random rand = new Random(System.currentTimeMillis());
    41 
    42         // **** DB
    43         // Some work to be done here => remove dependency in code on 'AUDIO_HOME_DIRECTORY'
    44         // and change it to use audio dir list from UserSettings
    45         public static void changeParentAndSubFolders(String newFolder) {
    46                
    47                 if (AuthenticatorBrowser.isAuthenticationRequired() && System.getProperty("user.name").equals(AuthenticatorBrowser.USER_NOBODY)) {
    48                         System.err.println("**** AudioPathManager::changeParentAndSubFolder(): Nothing to do for user '" + AuthenticatorBrowser.USER_NOBODY + "'");
    49                         return;
    50                 }
    51                
    52                 if (UserSettings.PublicAndPrivateResources) {
    53                         //String resourcesPublicPath = FrameIO.PARENT_FOLDER + "resources-public" + File.separator;
    54                         String userName = UserSettings.UserName.get();
    55                         //String resourcesPrivateIndividualPath = FrameIO.PARENT_FOLDER + "resources-" + userName + File.separator;
    56                         if (AuthenticatorBrowser.isAuthenticationRequired()) {
    57                                 System.err.println("**** AudioPathManager::changeParentAndSubFolder(): Setting 'audio' folder to resources-" + userName);
    58                         }
    59                         //AUDIO_HOME_DIRECTORY = resourcesPrivateIndividualPath + "audio" + File.separatorChar;
    60                         AUDIO_HOME_DIRECTORY = FrameIO.AUDIO_PRIVATE_PATH;
    61                 }
    62                 else {
    63                         AUDIO_HOME_DIRECTORY = FrameIO.PARENT_FOLDER + "audio" + File.separatorChar;;
    64                 }
    65         }
    66        
    67         public static void activateAndScanAudioDir()
    68         {
    69                 changeParentAndSubFolders(FrameIO.PARENT_FOLDER);
    70                
    71                 // Ensure audio directory exists
    72                 File dir = new File(AUDIO_HOME_DIRECTORY);
    73                 if (!dir.exists()) {
    74                         if (!dir.mkdir()) {
    75                                 ApolloSystemLog.println("Unable to create missing audio home directory");
    76                         }
    77                 }
    78 
     45       
     46        // TODO: this function called during startup?  In browser construction?  When FrameIO.changeParentAndSubFolders() is called?  Separation of apollo from expeditee core?
     47        public static void activateAndScanAudioDirs() {
     48                // If we are in old regime then there is no AUDIO_USERNAME_PRIVATE_PATH.
     49                AUDIO_USERNAME_HOME_DIRECTORY = FrameIO.AUDIO_USERNAME_PRIVATE_PATH == null ? FrameIO.AUDIO_PATH : FrameIO.AUDIO_USERNAME_PRIVATE_PATH;
     50               
    7951                // Load counter
    80                 loadCounter(AUDIO_HOME_DIRECTORY);
    81         }
    82        
     52                loadCounter();
     53        }
    8354       
    8455        /**
    8556         * Loads the counter
    86          * @param dir The dir where the audio files live.
    87          */
    88         private static void loadCounter(String audio_dir_str) {
    89                 File audio_dir = new File(audio_dir_str);
    90                
    91                 String[] files = getAudioFileNames(audio_dir);
    92                 if (files == null) { // Due to IO exception
    93                         ApolloSystemLog.printError("Failed to read audio directory");
    94                         return;
    95                 }
     57         */
     58        private static void loadCounter() {
     59                List<String> audioFileNames = getAudioFileNames();
     60               
    9661                long count = 0;
    97                 if (files != null) {
    98                         for (String f : files) {
    99        
    100                                 int start = -1, end = -1;
    101                                 for (int i = 0; i < f.length(); i++) {
    102                                         if (Character.isDigit(f.charAt(i)) && start == -1) {
    103                                                 start = i;
    104                                         } else if (!Character.isDigit(f.charAt(i)) && start != -1) {
    105                                                 end = i;
    106                                                 break;
    107                                         }
    108                                 }
    109                                
    110                                 if (start >= 0 && end == -1) {
    111                                         end = f.length();
    112                                 }
    113        
    114                                 if (start > 0 && end >= start) { // not start >= 0 since missing preable
    115        
    116                                         String tmp = f.substring(start, end);
    117                                         long l = Long.parseLong(tmp);
    118                                         if (l >= count)
    119                                                 count = l + 1;
    120                                 }
    121                         }
    122                 }
    123 
     62                for (String f : audioFileNames) {
     63                       
     64                        int start = -1, end = -1;
     65                        for (int i = 0; i < f.length(); i++) {
     66                                if (Character.isDigit(f.charAt(i)) && start == -1) {
     67                                        start = i;
     68                                } else if (!Character.isDigit(f.charAt(i)) && start != -1) {
     69                                        end = i;
     70                                        break;
     71                                }
     72                        }
     73                       
     74                        if (start >= 0 && end == -1) {
     75                                end = f.length();
     76                        }
     77
     78                        if (start > 0 && end >= start) { // not start >= 0 since missing preable
     79
     80                                String tmp = f.substring(start, end);
     81                                long l = Long.parseLong(tmp);
     82                                if (l >= count)
     83                                        count = l + 1;
     84                        }
     85                }
    12486                counter = count;
    125         }
    126        
    127         /**
    128          * @param dir
    129          * @return
    130          *              Null if an IO exception occurs
    131          */
    132         private static String[] getAudioFileNames(File dir) {
    133                 return dir.list(new RegExpFileFilter("^[A-Z]+\\d+.*$"));
    13487        }
    13588       
     
    14093         *              read list of files.
    14194         */
    142         public static String[] getAudioFileNames() {
    143                 File audioDir = new File(AUDIO_HOME_DIRECTORY);
    144                 if (!audioDir.exists() || !audioDir.isDirectory()) return null;
    145                 return getAudioFileNames(audioDir);
     95        public static List<String> getAudioFileNames() {
     96                Predicate<File> isFile = file -> {
     97                        File dirForFile = file.toPath().getParent().toFile();
     98                        if (!dirForFile.exists()) {
     99                                if (!dirForFile.mkdir()) {
     100                                        ApolloSystemLog.println("Unable to create missing audio directory: " + dirForFile.toString());
     101                                }
     102                        }
     103                        if (file.isFile()) {
     104                                return true;
     105                        }
     106                        return false;
     107                };             
     108                List<File> allFilesInAudioDirectories = ResourceManager.gatherAudioResources(isFile, DisplayController.getCurrentFrame());
     109                List<String> audioFileNames = new ArrayList<String>();
     110                RegExpFileFilter regExpFileFilter = new RegExpFileFilter("^[A-Z]+\\d+.*$");
     111                for (File file: allFilesInAudioDirectories) {
     112                        if (regExpFileFilter.accept(file, file.getAbsolutePath())) {
     113                                audioFileNames.add(file.getName());
     114                        }
     115                }
     116                return audioFileNames;
    146117        }
    147118       
     
    168139                String filename = generateRandomFilenameBase() + "." + extension;
    169140               
    170                 File f = new File(AUDIO_HOME_DIRECTORY + filename);
     141                File f = new File(AUDIO_USERNAME_HOME_DIRECTORY + filename);
    171142
    172143                if (AudioStructureModel.getInstance().getTrackGraphInfo(filename, null) != null ||
     
    206177
    207178                // Build the filename string
    208                 return preamble + counter;
     179                return UserSettings.UserName.get() + preamble + counter;
    209180               
    210181        }
     
    222193
    223194                // Ensure that the name base file exists. Assumes the audio home directory exists.
    224                 File vnameBase = new File(AUDIO_HOME_DIRECTORY + VIRTUAL_NAME_BASEFILE);
     195                File vnameBase = new File(AUDIO_USERNAME_HOME_DIRECTORY + VIRTUAL_NAME_BASEFILE);
    225196                if (!vnameBase.exists()) {
    226197                        try {
  • trunk/src/org/apollo/util/AudioPurger.java

    r1244 r1434  
    1111import org.apollo.widgets.SampledTrack;
    1212import org.expeditee.settings.folders.FolderSettings;
     13import org.expeditee.gui.DisplayController;
     14import org.expeditee.gui.management.ResourceManager;
    1315import org.expeditee.items.ItemUtils;
    1416
     
    2628        public static void purgeLocalAudio() {
    2729               
    28                 String[] audioFiles = AudioPathManager.getAudioFileNames();
    29                 if (audioFiles == null || audioFiles.length == 0) return;
     30                List<String> audioFiles = AudioPathManager.getAudioFileNames();
     31                if (audioFiles == null || audioFiles.size() == 0) return;
    3032               
    3133               
     
    5052                for (String audioFile : audioFiles) {
    5153                        if (!referencedAudio.contains(audioFile)) {
    52                                
    53                                 File unreferencedFile = new File(AudioPathManager.AUDIO_HOME_DIRECTORY + audioFile);
     54                                File unreferencedFile = ResourceManager.getAudioResource(audioFile, DisplayController.getCurrentFrame());
     55                                //File unreferencedFile = new File(AudioPathManager.AUDIO_HOME_DIRECTORY + audioFile);
    5456                                ApolloSystemLog.println("Deleting unreference audio file \"" + audioFile + "\"");
    5557                                unreferencedFile.delete();
    5658                               
    5759                                // Also delete any melody meta
    58                                 File melodyMetaFile = new File(
    59                                                 AudioPathManager.AUDIO_HOME_DIRECTORY +
    60                                                 MelodySearch.MELODY_METAFILE_PREFIX +
    61                                                 audioFile +
    62                                                 MelodySearch.MELODY_METAFILE_SUFFIX);
     60                                String melodyFileName = MelodySearch.MELODY_METAFILE_PREFIX + audioFile + MelodySearch.MELODY_METAFILE_SUFFIX;
     61                                File melodyMetaFile = ResourceManager.getAudioResource(melodyFileName, DisplayController.getCurrentFrame());
    6362                               
    6463                                if (melodyMetaFile.exists()) melodyMetaFile.delete();
  • trunk/src/org/apollo/widgets/FramePlayer.java

    r1102 r1434  
    107107               
    108108                // Read typed frames
    109                 File f = new File(AudioPathManager.AUDIO_HOME_DIRECTORY + TYPED_FRAMED_HISTORY_FILE);
     109                File f = new File(AudioPathManager.AUDIO_USERNAME_HOME_DIRECTORY + TYPED_FRAMED_HISTORY_FILE);
    110110                if (f.exists()) {
    111111                        BufferedReader in = null;
     
    147147                try {
    148148                        // Open the vbase for appending
    149                         out = new FileWriter(AudioPathManager.AUDIO_HOME_DIRECTORY + TYPED_FRAMED_HISTORY_FILE, false);
     149                        out = new FileWriter(AudioPathManager.AUDIO_USERNAME_HOME_DIRECTORY + TYPED_FRAMED_HISTORY_FILE, false);
    150150                        for (String str : typedFrameNames) {
    151151                                out.write(str + "\n");
     
    802802                }
    803803               
    804             ComboBoxModel<String> model = new DefaultComboBoxModel<String>((String[]) orderedModelData.toArray());
     804            ComboBoxModel<String> model = new DefaultComboBoxModel<String>((String[]) orderedModelData.toArray(new String[] {}));
     805                //ComboBoxModel model = new DefaultComboBoxModel(orderedModelData.toArray());
    805806           
    806807            // Remove helper tags from model data
  • trunk/src/org/apollo/widgets/SampledTrack.java

    r1179 r1434  
    2323import javax.sound.sampled.LineUnavailableException;
    2424import javax.sound.sampled.UnsupportedAudioFileException;
     25import javax.swing.JSlider;
    2526import javax.swing.SwingUtilities;
    2627
     
    7071import org.expeditee.gui.FrameIO;
    7172import org.expeditee.gui.PopupManager;
     73import org.expeditee.gui.management.ResourceManager;
    7274import org.expeditee.items.ItemParentStateChangedEvent;
    7375import org.expeditee.items.ItemUtils;
     
    401403               
    402404                });
    403                
     405                               
    404406                fulltrackView.addKeyListener(new KeyListener() {
    405407
    406408                        @Override
    407                         public void keyPressed(KeyEvent e)
    408                         {
     409                        public void keyPressed(KeyEvent e) {
    409410                        }
    410411
    411412                        @Override
    412                         public void keyReleased(KeyEvent e)
    413                         {
     413                        public void keyReleased(KeyEvent e)     {
     414                               
     415                                // On 26th September, Bryce added P M + - keys to play/pause/resume, mute and adjust volume.
     416                                if (e.isControlDown() && e.getKeyCode() == KeyEvent.VK_P) {
     417                                        try {
     418                                                playbackControlPopup.playPauseResume();
     419                                        } catch (LineUnavailableException e1) {
     420                                                e1.printStackTrace();
     421                                        }
     422                                } else if (e.isControlDown() && e.getKeyCode() == KeyEvent.VK_M) {
     423                                        boolean selected = playbackControlPopup.muteButton.isSelected();
     424                                        playbackControlPopup.muteButton.setSelected(!selected);
     425                                        playbackControlPopup.muteChanged();
     426                                } else if (e.isControlDown() && e.getKeyCode() == KeyEvent.VK_SUBTRACT) {
     427                                        JSlider volumeSlider = playbackControlPopup.volumeSlider;
     428                                        int delta = Math.round(((float) (volumeSlider.getMaximum() - volumeSlider.getMinimum())) / 10f);
     429                                        int newVolume = Math.max(volumeSlider.getValue() - delta, volumeSlider.getMinimum());
     430                                        volumeSlider.setValue(newVolume);
     431                                        playbackControlPopup.volumeChanged();
     432                                } else if (e.isControlDown() && e.getKeyCode() == KeyEvent.VK_ADD) {
     433                                        JSlider volumeSlider = playbackControlPopup.volumeSlider;
     434                                        int delta = Math.round(((float) (volumeSlider.getMaximum() - volumeSlider.getMinimum())) / 10f);
     435                                        int newVolume = Math.min(volumeSlider.getValue() + delta, volumeSlider.getMaximum());
     436                                        volumeSlider.setValue(newVolume);
     437                                        playbackControlPopup.volumeChanged();
     438                                }
     439                               
    414440                                // Toggle pitch-track indexing
    415                                 if (e.isControlDown() && e.getKeyCode() == KeyEvent.VK_I) {
     441                                else if (e.isControlDown() && e.getKeyCode() == KeyEvent.VK_I) {
    416442                                        setShouldOmitIndexAudio(!shouldOmitIndexAudio());
    417443                                        DisplayController.requestRefresh(true);
     
    765791                                setLoadScreenMessage("Loading audio file...");
    766792                               
    767                                 f = new File(
    768                                                 AudioPathManager.AUDIO_HOME_DIRECTORY + localFileName);
     793                                //f = new File(
     794                                //              AudioPathManager.AUDIO_HOME_DIRECTORY + localFileName);
     795                                f = ResourceManager.getAudioResource(localFileName, getParentFrame());
    769796                        }
    770797                       
     
    809836                                        // If recovering - might be recovering an existing track that had been
    810837                                        // saved to the repository .. thus re-use the old file
    811                                         trackModel.setFilepath(AudioPathManager.AUDIO_HOME_DIRECTORY + localFileName);
     838                                        File audioResource = ResourceManager.getAudioResource(localFileName, getParentFrame());
     839                                        trackModel.setFilepath(audioResource.getAbsolutePath());
    812840                                }
    813841                               
     
    940968                // If saving for the file time then get a filename
    941969                if (trackModel.getFilepath() == null) {
    942                         trackModel.setFilepath(AudioPathManager.AUDIO_HOME_DIRECTORY + localFileName);
     970                        File audioResource = ResourceManager.getAudioResource(localFileName, DisplayController.getCurrentFrame());
     971                        trackModel.setFilepath(audioResource.getAbsolutePath());
    943972                        loadFilenameArgument = localFileName; // set to now local, next load will be local
    944973                }
     
    10291058               
    10301059                // Get rid of local file
    1031                 File oldLocalFile = new File(AudioPathManager.AUDIO_HOME_DIRECTORY + localFileName);
     1060                //File oldLocalFile = new File(AudioPathManager.AUDIO_HOME_DIRECTORY + localFileName);
     1061                File oldLocalFile = ResourceManager.getAudioResource(localFileName, getParentFrame());
    10321062                if (oldLocalFile.isFile() && oldLocalFile.exists()) {
    10331063                        try {
     
    11571187                        return recoveryFile.getAbsolutePath();
    11581188                }
    1159                        
    1160                 return AudioPathManager.AUDIO_HOME_DIRECTORY + localFileName;
     1189               
     1190                File audioResource = ResourceManager.getAudioResource(localFileName, getParentFrame());                 
     1191                return audioResource.getAbsolutePath();
    11611192               
    11621193               
     
    20052036                                try {
    20062037       
    2007                                         if (!SoundDesk.getInstance().isPlaying(trackMix.getChannelID())) { // play / resume
    2008                                                
    2009                                                 int startFrame = -1, endFrame = -1;
    2010                                                
    2011                                                 // Resume playback?
    2012                                                 if (SoundDesk.getInstance().isPaused(trackMix.getChannelID())) {
    2013                                                         startFrame = SoundDesk.getInstance().getLastPlayedFramePosition(trackMix.getChannelID());
    2014                                                         if (startFrame >= 0 && startFrame < trackModel.getFrameCount()) {
    2015                                
    2016                                                                 // The user may have edited the audio track and reselected it
    2017                                                                 // since the last pause. Thus select an appropriate end frame
    2018                                                                 endFrame = (trackModel.getSelectionLength() > 1) ?
    2019                                                                                 trackModel.getSelectionStart() + trackModel.getSelectionLength():
    2020                                                                                         trackModel.getFrameCount() - 1;
    2021                                                                        
    2022                                                                 // Changed selection? it play range invalid?
    2023                                                                 if (endFrame <= startFrame || startFrame < trackModel.getSelectionStart()) {
    2024                                                                         startFrame = -1; // Play new selection (see below)
    2025                                                                
    2026                                                                 } else if (endFrame >= trackModel.getFrameCount()) {
    2027                                                                         endFrame = trackModel.getFrameCount() - 1;
    2028                                                                 }               
    2029                                                                
    2030                                                         }
    2031                                                 }
    2032                                                
    2033                                                 // Play from beginning of selection to end of selection
    2034                                                 if (startFrame < 0) {
    2035                                                         startFrame = trackModel.getSelectionStart();
    2036                                                         endFrame = (trackModel.getSelectionLength() > 1) ?
    2037                                                                         startFrame + trackModel.getSelectionLength():
    2038                                                                                 trackModel.getFrameCount() - 1;
    2039                                                 }
    2040        
    2041                                                 // Safety clamp:
    2042                                                 if (endFrame >= trackModel.getFrameCount()) {
    2043                                                         endFrame = trackModel.getFrameCount() - 1;
    2044                                                 }       
    2045                                                
    2046                                                 if (startFrame < endFrame) {
    2047                                                         SoundDesk.getInstance().playSampledTrackModel(
    2048                                                                         trackModel,
    2049                                                                         trackMix.getChannelID(),
    2050                                                                         startFrame,
    2051                                                                         endFrame,
    2052                                                                         0);
    2053                                                 }
    2054        
    2055                                         } else { // pause
    2056                                                
    2057                                                 TrackSequence ts = SoundDesk.getInstance().getTrackSequence(trackMix.getChannelID());
    2058 
    2059                                                 if (ts != null &&
    2060                                                                 ts.isPlaying()) {
    2061                                                        
    2062                                                         // Mark channel as paused.
    2063                                                         SoundDesk.getInstance().setPaused(trackMix.getChannelID(), true);
    2064                                                        
    2065                                                         // Stop playback for this channel
    2066                                                         ApolloPlaybackMixer.getInstance().stop(ts);
    2067                                                        
    2068                                                 }
    2069                                                
    2070                                         }
     2038                                        playPauseResume();
    20712039                                       
    20722040                                } catch (LineUnavailableException e1) {
     
    20942062                        } else if (e.getSource() == miscButton) {
    20952063                                expand(false);
     2064                        }
     2065                }
     2066
     2067                private void playPauseResume() throws LineUnavailableException {
     2068                        if (!SoundDesk.getInstance().isPlaying(trackMix.getChannelID())) { // play / resume
     2069                               
     2070                                int startFrame = -1, endFrame = -1;
     2071                               
     2072                                // Resume playback?
     2073                                if (SoundDesk.getInstance().isPaused(trackMix.getChannelID())) {
     2074                                        startFrame = SoundDesk.getInstance().getLastPlayedFramePosition(trackMix.getChannelID());
     2075                                        if (startFrame >= 0 && startFrame < trackModel.getFrameCount()) {
     2076
     2077                                                // The user may have edited the audio track and reselected it
     2078                                                // since the last pause. Thus select an appropriate end frame
     2079                                                endFrame = (trackModel.getSelectionLength() > 1) ?
     2080                                                                trackModel.getSelectionStart() + trackModel.getSelectionLength():
     2081                                                                        trackModel.getFrameCount() - 1;
     2082                                                       
     2083                                                // Changed selection? it play range invalid?
     2084                                                if (endFrame <= startFrame || startFrame < trackModel.getSelectionStart()) {
     2085                                                        startFrame = -1; // Play new selection (see below)
     2086                                               
     2087                                                } else if (endFrame >= trackModel.getFrameCount()) {
     2088                                                        endFrame = trackModel.getFrameCount() - 1;
     2089                                                }               
     2090                                               
     2091                                        }
     2092                                }
     2093                               
     2094                                // Play from beginning of selection to end of selection
     2095                                if (startFrame < 0) {
     2096                                        startFrame = trackModel.getSelectionStart();
     2097                                        endFrame = (trackModel.getSelectionLength() > 1) ?
     2098                                                        startFrame + trackModel.getSelectionLength():
     2099                                                                trackModel.getFrameCount() - 1;
     2100                                }
     2101
     2102                                // Safety clamp:
     2103                                if (endFrame >= trackModel.getFrameCount()) {
     2104                                        endFrame = trackModel.getFrameCount() - 1;
     2105                                }       
     2106                               
     2107                                if (startFrame < endFrame) {
     2108                                        SoundDesk.getInstance().playSampledTrackModel(
     2109                                                        trackModel,
     2110                                                        trackMix.getChannelID(),
     2111                                                        startFrame,
     2112                                                        endFrame,
     2113                                                        0);
     2114                                }
     2115
     2116                        } else { // pause
     2117                               
     2118                                TrackSequence ts = SoundDesk.getInstance().getTrackSequence(trackMix.getChannelID());
     2119
     2120                                if (ts != null &&
     2121                                                ts.isPlaying()) {
     2122                                       
     2123                                        // Mark channel as paused.
     2124                                        SoundDesk.getInstance().setPaused(trackMix.getChannelID(), true);
     2125                                       
     2126                                        // Stop playback for this channel
     2127                                        ApolloPlaybackMixer.getInstance().stop(ts);
     2128                                       
     2129                                }
     2130                               
    20962131                        }
    20972132                }
Note: See TracChangeset for help on using the changeset viewer.