Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 5dfd0bf8ff
Fetching contributors…

Cannot retrieve contributors at this time

executable file 5892 lines (5056 sloc) 233.435 kb
//
// DetailViewController.m
// modizer1
//
// Created by Yohann Magnien on 04/06/10.
// Copyright __YoyoFR / Yohann Magnien__ 2010. All rights reserved.
//
#import <mach/mach.h>
#import <mach/mach_host.h>
#define MIDIFX_OFS 10
#define LOCATION_UPDATE_TIMING 1800 //in second : 30minutes
#define NOTES_DISPLAY_LEFTMARGIN 30
#define NOTES_DISPLAY_TOPMARGIN 30
#include <sys/types.h>
#include <sys/sysctl.h>
#include "TextureUtils.h"
#include "DBHelper.h"
#define DEBUG_NO_SETTINGS 0
#include "OGLView.h"
#include "RenderUtils.h"
#include "FXFluid.h"
#include <QuartzCore/CADisplayLink.h>
#import <OpenGLES/EAGLDrawable.h>
#include <OpenGLES/ES1/glext.h>
#import <QuartzCore/QuartzCore.h>
#import "UIImageResize.h"
#import "DetailViewControllerIphone.h"
#import "RootViewControllerIphone.h"
#import <MediaPlayer/MediaPlayer.h>
#import "modplug.h"
#import "gme.h"
#import "math.h"
#import "Font.h"
#import "GLString.h"
#import "timidity.h"
#import "AnimatedGif.h"
extern "C" {
int fix_fftr(short int f[], int m, int inverse);
int fix_fft(short int fr[], short int fi[], short int m, short int inverse);
}
extern int tim_notes_cpy[SOUND_BUFFER_NB][DEFAULT_VOICES];
extern unsigned char tim_voicenb_cpy[SOUND_BUFFER_NB];
extern char mplayer_error_msg[1024];
int tim_midifx_note_range,tim_midifx_note_offset;
static int mOnlyCurrentEntry;
static int mOnlyCurrentSubEntry;
extern volatile int db_checked;
static int shouldRestart;
//static volatile int locManager_isOn;
static int coverflow_plsize,coverflow_pos,coverflow_needredraw;
static BOOL mOglViewIsHidden;
static volatile int mSendStatTimer;
static NSDate *locationLastUpdate=nil;
static double located_lat=999,located_lon=999;
int mDevice_hh,mDevice_ww;
static int mShouldHaveFocusAfterBackground,mShouldUpdateInfos,mLoadIssueMessage;
static int mRandomFXCpt,mRandomFXCptRev;
static int infoIsFullscreen=0;
static int plIsFullscreen=0;
static UIAlertView *alertCrash;
static MPVolumeView *volumeView;
static int txtMenuHandle[16];
static int mValidatePlName=0;
static int mSavePlaylist=0;
static volatile int mPopupAnimation=0;
//static UIAlertView *alertCannotPlay;
static int alertCannotPlay_displayed;
static uint touch_cpt=0;
static int viewTapHelpInfo=0;
static int viewTapHelpShow=0;
static NSString *located_country=nil,*located_city=nil;
static UIImage *covers_default; // album covers images
//#define TOUCH_CPT_INIT 5 //20 is 1s (20frames)
#define TOUCH_KEPT_THRESHOLD 10
#define max2(a,b) (a>b?a:b)
#define max4(a,b,c,d) max2(max2(a,b),max2(c,d))
#define max8(a,b,c,d,e,f,g,h) max2(max4(a,b,c,d),max4(e,f,g,h))
@implementation DetailViewControllerIphone
@synthesize coverflow,lblMainCoverflow,lblSecCoverflow,lblCurrentSongCFlow,lblTimeFCflow;
@synthesize btnPlayCFlow,btnPauseCFlow,btnBackCFlow;
@synthesize sld_DefaultLength,labelDefaultLength;
@synthesize mDeviceType;
@synthesize cover_view,gifAnimation;
//@synthesize locManager;
@synthesize sc_allowPopup,infoMsgView,infoMsgLbl,sc_titleFilename;
@synthesize mIsPlaying,mPaused,mplayer,mPlaylist;
@synthesize detailItem, detailDescriptionLabel;
@synthesize labelModuleName, labelTime, labelModuleLength, labelModuleSize,textMessage,labelNumChannels,labelModuleType,labelSeeking,labelLibName;
@synthesize buttonLoopTitleSel,buttonLoopList,buttonLoopListSel,buttonShuffle,buttonShuffleSel,btnLoopInf;
@synthesize repeatingTimer;
@synthesize sliderProgressModule;
@synthesize playlistView,playlistTabView,detailView,commandViewU,volWin,playlistPos;
@synthesize surDepSld,surDelSld,revDepSld,revDelSld,bassAmoSld,bassRanSld,mastVolSld,mpPanningSld,sldFxAlpha;
@synthesize playBar,pauseBar,playBarSub,pauseBarSub;
@synthesize mainView,infoView;
@synthesize rating1,rating1off,rating2,rating2off,rating3,rating3off,rating4,rating4off,rating5,rating5off;
@synthesize mainRating1,mainRating1off,mainRating2,mainRating2off,mainRating3,mainRating3off,mainRating4,mainRating4off,mainRating5,mainRating5off;
@synthesize mShouldHaveFocus,mHasFocus,mScaleFactor;
@synthesize mParentViewController;
@synthesize infoButton,backInfo,backPlaylist;
@synthesize mPlaylist_pos,mPlaylist_size;
//,mPlaylistFilenames,mPlaylistFilepaths;
@synthesize segcont_oscillo,segcont_forceMono,sc_checkBeforeRedownload,sc_bgPlay,sc_StatsUpload,sc_SpokenTitle,sc_showDebug;
//segcont_resumeLaunch
@synthesize segcont_spectrum,segcont_shownote,segcont_mpSampling;
@synthesize segcont_mpMB,segcont_mpReverb,segcont_mpSUR,segcont_fx1,segcont_fx2,segcont_fx3,segcont_fx4,segcont_fx5,segcont_FxBeat,sc_FXDetail,sc_cflow,sc_AOSDKDSFDSP,sc_AOSDKDSFEmuRatio,sc_AOSDKSSFDSP,sc_AOSDKSSFEmuRatio;
@synthesize sc_SEXYPSF_Reverb,sc_SEXYPSF_Interpol;
@synthesize sc_AOSDK_Reverb,sc_AOSDK_Interpol;
@synthesize sc_ADPLUG_opltype;
@synthesize labelTimPolyphony,sld_TIMPoly;
@synthesize oglButton;
@synthesize sldDUMBMastVol,labelDUMBMastVol,sc_DUMBResampling;
@synthesize pvSubSongSel,pvSubSongLabel,pvSubSongValidate,btnShowSubSong;
@synthesize pvArcSel,pvArcLabel,pvArcValidate,btnShowArcList;
@synthesize sc_AfterDownload,sc_EnqueueMode,sc_DefaultAction,segcont_randFx,sc_defaultMODplayer,sc_PlayerViewOnPlay;
@synthesize sc_UADE_Led,sc_UADE_Norm,sc_UADE_PostFX,sc_UADE_Pan,sc_UADE_Head,sc_UADE_Gain,sc_SID_Optim,sc_SID_LibVersion,sc_SID_Filter;
@synthesize sld_UADEpan,sld_UADEgain;
@synthesize sc_TIMreverb,sc_TIMfilter,sc_TIMresample,sc_TIMchorus;
@synthesize sldPanning,sc_Panning,lblPanningValue;
@synthesize btnSortPlAZ,btnSortPlZA,btnPlShuffle,btnPlClear,btnPlEdit,btnPlOk;
@synthesize infoZoom,infoUnzoom,plZoom,plUnzoom;
@synthesize mPlWasView,mInWasView;
@synthesize inputText,textInputView,rootViewControllerIphone,mSlowDevice;
-(IBAction)showSubSongSelector {
if (pvSubSongSel.hidden) {
pvSubSongSel.hidden=false;
pvSubSongLabel.hidden=false;
pvSubSongValidate.hidden=false;
[pvSubSongSel selectRow:mplayer.mod_currentsub-mplayer.mod_minsub inComponent:0 animated:TRUE];
/* [UIView beginAnimations:nil context:nil];
[UIView setAnimationDelay:0.2];
[UIView setAnimationDuration:0.70];
[UIView setAnimationDelegate:self];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.pvSubSongValidate cache:YES];
[UIView commitAnimations];*/
}
else {
pvSubSongSel.hidden=true;
pvSubSongLabel.hidden=true;
pvSubSongValidate.hidden=true;
}
}
-(IBAction)showArcSelector {
if (pvArcSel.hidden) {
pvArcSel.hidden=false;
pvArcLabel.hidden=false;
pvArcValidate.hidden=false;
[pvArcSel selectRow:[mplayer getArcIndex] inComponent:0 animated:TRUE];
/* [UIView beginAnimations:nil context:nil];
[UIView setAnimationDelay:0.2];
[UIView setAnimationDuration:0.70];
[UIView setAnimationDelegate:self];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.pvArcValidate cache:YES];
[UIView commitAnimations];*/
}
else {
pvArcSel.hidden=true;
pvArcLabel.hidden=true;
pvArcValidate.hidden=true;
}
}
-(IBAction)optGENTitleFilename {
if (mPlaylist_pos>=mPlaylist_size) return;
NSString *fileName=mPlaylist[mPlaylist_pos].mPlaylistFilename;
if (sc_titleFilename.selectedSegmentIndex) labelModuleName.text=[NSString stringWithString:fileName];
else labelModuleName.text=[NSString stringWithString:[mplayer getModName]];
lblCurrentSongCFlow.text=labelModuleName.text;
}
-(IBAction)pushedLoopInf {
if (mplayer.mLoopMode==0) {
[mplayer setLoopInf:1];
[btnLoopInf setTitleColor:[UIColor colorWithRed:0.3f green:0.5f blue:1.0f alpha:1.0f] forState:UIControlStateNormal];
if (mPaused==0) [self play_curEntry];
} else {
[mplayer setLoopInf:0];
[btnLoopInf setTitleColor:[UIColor colorWithRed:0.3f green:0.3f blue:0.3f alpha:1.0f] forState:UIControlStateNormal];
if (mPaused==0) [self play_curEntry];
}
}
-(IBAction) oglButtonPushed {
if (mOglViewIsHidden) mOglViewIsHidden=NO;
else mOglViewIsHidden=YES;
[self checkGLViewCanDisplay];
}
-(IBAction)ADPLUG_OptChanged {
[mplayer optADPLUG:sc_ADPLUG_opltype.selectedSegmentIndex];
}
-(IBAction)AOSDK_OptChanged {
[mplayer optAOSDK:sc_AOSDK_Reverb.selectedSegmentIndex interpol:sc_AOSDK_Interpol.selectedSegmentIndex];
}
-(IBAction)SEXYPSF_OptChanged {
[mplayer optSEXYPSF:sc_SEXYPSF_Reverb.selectedSegmentIndex interpol:sc_SEXYPSF_Interpol.selectedSegmentIndex];
}
-(IBAction)optSID_Optim {
mplayer.optSIDoptim=(int)(sc_SID_Optim.selectedSegmentIndex);
}
-(IBAction)optSID_Filter {
[mplayer optSIDFilter:sc_SID_Filter.selectedSegmentIndex];
}
-(IBAction)optSID_LibVersion {
mplayer.mAskedSidEngineType =(int)(sc_SID_LibVersion.selectedSegmentIndex)+1;
}
-(IBAction) optUADE_Led {
[mplayer optUADE_Led:sc_UADE_Led.selectedSegmentIndex];
}
-(IBAction) optUADE_PostFX {
[mplayer optUADE_PostFX:sc_UADE_PostFX.selectedSegmentIndex];
}
-(IBAction) optUADE_Norm {
if ((sc_UADE_Norm.selectedSegmentIndex==1)&&(sc_UADE_PostFX.selectedSegmentIndex==0)) {
sc_UADE_PostFX.selectedSegmentIndex=1;
[mplayer optUADE_PostFX:sc_UADE_PostFX.selectedSegmentIndex];
}
[mplayer optUADE_Norm:sc_UADE_Norm.selectedSegmentIndex];
}
-(IBAction) optUADE_Pan {
if ((sc_UADE_Pan.selectedSegmentIndex==1)&&(sc_UADE_PostFX.selectedSegmentIndex==0)) {
sc_UADE_PostFX.selectedSegmentIndex=1;
[mplayer optUADE_PostFX:sc_UADE_PostFX.selectedSegmentIndex];
}
[mplayer optUADE_Pan:sc_UADE_Pan.selectedSegmentIndex];
}
-(IBAction) optUADE_Head {
if ((sc_UADE_Head.selectedSegmentIndex==1)&&(sc_UADE_PostFX.selectedSegmentIndex==0)) {
sc_UADE_PostFX.selectedSegmentIndex=1;
[mplayer optUADE_PostFX:sc_UADE_PostFX.selectedSegmentIndex];
}
[mplayer optUADE_Head:sc_UADE_Head.selectedSegmentIndex];
}
-(IBAction) optUADE_Gain {
if ((sc_UADE_Gain.selectedSegmentIndex==1)&&(sc_UADE_PostFX.selectedSegmentIndex==0)) {
sc_UADE_PostFX.selectedSegmentIndex=1;
[mplayer optUADE_PostFX:sc_UADE_PostFX.selectedSegmentIndex];
}
[mplayer optUADE_Gain:sc_UADE_Gain.selectedSegmentIndex];
}
-(IBAction) optUADE_PanValue {
[mplayer optUADE_PanValue:sld_UADEpan.value];
}
-(IBAction) optUADE_GainValue {
[mplayer optUADE_GainValue:sld_UADEgain.value];
}
-(IBAction) optGEN_DefaultLength {
[mplayer optGEN_DefaultLength:sld_DefaultLength.value];
labelDefaultLength.text=[NSString stringWithFormat:@"Default length %d:%.2d",(int)(sld_DefaultLength.value)/60,(int)(sld_DefaultLength.value)%60];
}
-(IBAction) optFX_Alpha {
// m_oglView.alpha=;
if (sldFxAlpha.value==1.0f) m_oglView.layer.opaque = YES;
else m_oglView.layer.opaque = NO;
}
-(IBAction) optGLOB_Panning {
[mplayer optGLOB_Panning:sc_Panning.selectedSegmentIndex];
}
-(IBAction) optGLOB_PanningValue {
[mplayer optGLOB_PanningValue:sldPanning.value];
lblPanningValue.text=[NSString stringWithFormat:@"Panning value: %.2f",sldPanning.value];
}
-(IBAction) optDUMBMastVol {
[mplayer optDUMB_MastVol:sldDUMBMastVol.value];
labelDUMBMastVol.text=[NSString stringWithFormat:@"%.2f",sldDUMBMastVol.value];
}
-(IBAction) optDUMBResampling {
[mplayer optDUMB_Resampling:sc_DUMBResampling.selectedSegmentIndex];
}
-(IBAction) optAOSDK_DSFDSP {
[mplayer optAOSDK_DSFDSP:sc_AOSDKDSFDSP.selectedSegmentIndex];
}
-(IBAction) optAOSDK_DSFEmuRatio {
[mplayer optAOSDK_DSFEmuRatio:sc_AOSDKDSFEmuRatio.selectedSegmentIndex];
}
-(IBAction) optAOSDK_SSFDSP {
[mplayer optAOSDK_SSFDSP:sc_AOSDKSSFDSP.selectedSegmentIndex];
}
-(IBAction) optAOSDK_SSFEmuRatio {
[mplayer optAOSDK_SSFEmuRatio:sc_AOSDKSSFEmuRatio.selectedSegmentIndex];
}
-(IBAction) optTIM_Polyphony {
[mplayer optTIM_Poly:(int)(sld_TIMPoly.value)];
labelTimPolyphony.text=[NSString stringWithFormat:@"%d voices",(int)(sld_TIMPoly.value)];
}
- (void)showRating:(int)rating {
rating1.hidden=TRUE;rating2.hidden=TRUE;rating3.hidden=TRUE;rating4.hidden=TRUE;rating5.hidden=TRUE;
rating1off.hidden=FALSE;rating2off.hidden=FALSE;rating3off.hidden=FALSE;rating4off.hidden=FALSE;rating5off.hidden=FALSE;
mainRating1.hidden=TRUE;mainRating2.hidden=TRUE;mainRating3.hidden=TRUE;mainRating4.hidden=TRUE;mainRating5.hidden=TRUE;
mainRating1off.hidden=FALSE;mainRating2off.hidden=FALSE;mainRating3off.hidden=FALSE;mainRating4off.hidden=FALSE;mainRating5off.hidden=FALSE;
switch (rating) {
case 5:
rating5.hidden=FALSE;rating5off.hidden=TRUE;
mainRating5.hidden=FALSE;mainRating5off.hidden=TRUE;
case 4:
rating4.hidden=FALSE;rating4off.hidden=TRUE;
mainRating4.hidden=FALSE;mainRating4off.hidden=TRUE;
case 3:
rating3.hidden=FALSE;rating3off.hidden=TRUE;
mainRating3.hidden=FALSE;mainRating3off.hidden=TRUE;
case 2:
rating2.hidden=FALSE;rating2off.hidden=TRUE;
mainRating2.hidden=FALSE;mainRating2off.hidden=TRUE;
case 1:
rating1.hidden=FALSE;rating1off.hidden=TRUE;
mainRating1.hidden=FALSE;mainRating1off.hidden=TRUE;
case 0:
break;
}
}
-(void) pushedRatingCommon:(short int)playcount{
if ([mplayer getSongLength]>0) {
DBHelper::updateFileStatsDBmod(mPlaylist[mPlaylist_pos].mPlaylistFilename,mPlaylist[mPlaylist_pos].mPlaylistFilepath,playcount,mRating,[mplayer getSongLength],mplayer.numChannels,(mOnlyCurrentEntry==0?([mplayer isArchive]?-[mplayer getArcEntriesCnt]:mplayer.mod_subsongs):-1) );
}
else DBHelper::updateFileStatsDBmod(mPlaylist[mPlaylist_pos].mPlaylistFilename,mPlaylist[mPlaylist_pos].mPlaylistFilepath,playcount,mRating);
if (sc_StatsUpload.selectedSegmentIndex) {
mSendStatTimer=0;
[GoogleAppHelper SendStatistics:mPlaylist[mPlaylist_pos].mPlaylistFilename path:mPlaylist[mPlaylist_pos].mPlaylistFilepath rating:mRating playcount:playcount country:located_country city:located_city longitude:located_lon latitude:located_lat];
}
mPlaylist[mPlaylist_pos].mPlaylistRating=mRating;
[self showRating:mRating];
[playlistTabView reloadData];
NSIndexPath *myindex=[[[NSIndexPath alloc] initWithIndex:0] autorelease];
[self.playlistTabView selectRowAtIndexPath:[myindex indexPathByAddingIndex:mPlaylist_pos] animated:TRUE scrollPosition:UITableViewScrollPositionMiddle];
}
-(IBAction)pushedRating1{
short int playcount=0;
if (!mPlaylist_size) return;
DBHelper::getFileStatsDBmod(mPlaylist[mPlaylist_pos].mPlaylistFilename,mPlaylist[mPlaylist_pos].mPlaylistFilepath,&playcount,&mRating);
if (mRating==1) mRating=0;
else mRating=1;
[self pushedRatingCommon:playcount];
}
-(IBAction)pushedRating2{
short int playcount=0;
if (!mPlaylist_size) return;
DBHelper::getFileStatsDBmod(mPlaylist[mPlaylist_pos].mPlaylistFilename,mPlaylist[mPlaylist_pos].mPlaylistFilepath,&playcount,&mRating);
mRating=2;
[self pushedRatingCommon:playcount];
}
-(IBAction)pushedRating3{
short int playcount=0;
if (!mPlaylist_size) return;
DBHelper::getFileStatsDBmod(mPlaylist[mPlaylist_pos].mPlaylistFilename,mPlaylist[mPlaylist_pos].mPlaylistFilepath,&playcount,&mRating);
mRating=3;
[self pushedRatingCommon:playcount];
}
-(IBAction)pushedRating4{
short int playcount=0;
if (!mPlaylist_size) return;
DBHelper::getFileStatsDBmod(mPlaylist[mPlaylist_pos].mPlaylistFilename,mPlaylist[mPlaylist_pos].mPlaylistFilepath,&playcount,&mRating);
mRating=4;
[self pushedRatingCommon:playcount];
}
-(IBAction)pushedRating5{
short int playcount=0;
if (!mPlaylist_size) return;
DBHelper::getFileStatsDBmod(mPlaylist[mPlaylist_pos].mPlaylistFilename,mPlaylist[mPlaylist_pos].mPlaylistFilepath,&playcount,&mRating);
mRating=5;
[self pushedRatingCommon:playcount];
}
static char note2charA[12]={'C','C','D','D','E','F','F','G','G','A','A','B'};
static char note2charB[12]={'-','#','-','#','-','-','#','-','#','-','#','-'};
static char dec2hex[16]={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
static int currentPattern,currentRow,startChan,visibleChan,movePx,movePy;
- (IBAction)settingsChanged:(id)sender {
ModPlug_Settings *mpsettings;
mpsettings=[mplayer getMPSettings];
switch ( segcont_mpSampling.selectedSegmentIndex) {
case 0:mpsettings->mResamplingMode = MODPLUG_RESAMPLE_LINEAR;break;
case 1:mpsettings->mResamplingMode = MODPLUG_RESAMPLE_SPLINE;break;
case 2:mpsettings->mResamplingMode = MODPLUG_RESAMPLE_FIR;break;
case 3:mpsettings->mResamplingMode = MODPLUG_RESAMPLE_NEAREST;break;
}
mpsettings->mFlags|=MODPLUG_ENABLE_OVERSAMPLING|MODPLUG_ENABLE_NOISE_REDUCTION;
switch ( segcont_mpReverb.selectedSegmentIndex) {
case 1:mpsettings->mFlags|=MODPLUG_ENABLE_REVERB;break;
case 0:mpsettings->mFlags&=~MODPLUG_ENABLE_REVERB;break;
}
switch ( segcont_mpMB.selectedSegmentIndex) {
case 1:mpsettings->mFlags|=MODPLUG_ENABLE_MEGABASS;break;
case 0:mpsettings->mFlags&=~MODPLUG_ENABLE_MEGABASS;break;
}
switch ( segcont_mpSUR.selectedSegmentIndex) {
case 1:mpsettings->mFlags|=MODPLUG_ENABLE_SURROUND;break;
case 0:mpsettings->mFlags&=~MODPLUG_ENABLE_SURROUND;break;
}
switch ( segcont_forceMono.selectedSegmentIndex) {
case 1:mplayer.optForceMono=1;break;
case 0:mplayer.optForceMono=0;break;
}
if (segcont_fx2.selectedSegmentIndex&&segcont_fx3.selectedSegmentIndex) {
if (sender==segcont_fx2) segcont_fx3.selectedSegmentIndex=0;
else segcont_fx2.selectedSegmentIndex=0;
segcont_fx4.selectedSegmentIndex=0;
segcont_fx5.selectedSegmentIndex=0;
}
if (segcont_fx4.selectedSegmentIndex) {
if (sender==segcont_fx4) {
//segcont_fx1.selectedSegmentIndex=0;
segcont_fx2.selectedSegmentIndex=0;
segcont_fx3.selectedSegmentIndex=0;
segcont_fx5.selectedSegmentIndex=0;
}
}
if (segcont_fx5.selectedSegmentIndex) {
if (sender==segcont_fx5) {
//segcont_fx1.selectedSegmentIndex=0;
segcont_fx2.selectedSegmentIndex=0;
segcont_fx3.selectedSegmentIndex=0;
segcont_fx4.selectedSegmentIndex=0;
}
}
int size_chan=12*6;
if (segcont_shownote.selectedSegmentIndex==2) size_chan=6*6;
visibleChan=(m_oglView.frame.size.width-NOTES_DISPLAY_LEFTMARGIN)/size_chan;
if (startChan>mplayer.numChannels-visibleChan) startChan=mplayer.numChannels-visibleChan;
if (startChan<0) startChan=0;
tim_midifx_note_range=88; //88notes on a Piano
tim_midifx_note_offset=0;
[mplayer optTIM_Chorus:(int)(sc_TIMchorus.selectedSegmentIndex)];
[mplayer optTIM_Reverb:(int)(sc_TIMreverb.selectedSegmentIndex)];
[mplayer optTIM_Resample:(int)(sc_TIMresample.selectedSegmentIndex)];
[mplayer optTIM_LPFilter:(int)(sc_TIMfilter.selectedSegmentIndex)];
mpsettings->mReverbDepth=(int)(revDepSld.value*100.0f);
mpsettings->mReverbDelay=(int)(revDelSld.value*160.0f+40.0f);
mpsettings->mBassAmount=(int)(bassAmoSld.value*100.0f);
mpsettings->mBassRange=(int)(bassRanSld.value*80.0f+20.0f);
mpsettings->mStereoSeparation=(int)(mpPanningSld.value*255.0f+1);
mpsettings->mSurroundDepth=(int)(surDepSld.value*100.0f);
mpsettings->mSurroundDelay=(int)(surDelSld.value*35.0f+5.0f);
[mplayer setModPlugMasterVol:mastVolSld.value];
[mplayer updateMPSettings];
[self checkGLViewCanDisplay];
}
-(void) checkGLViewCanDisplay{
/*if ((segcont_fx1.selectedSegmentIndex==0)&&
(segcont_fx2.selectedSegmentIndex==0)&&
(segcont_fx3.selectedSegmentIndex==0)&&
(segcont_FxBeat.selectedSegmentIndex==0)&&
(segcont_spectrum.selectedSegmentIndex==0)&&
(segcont_oscillo.selectedSegmentIndex==0)&&
((segcont_shownote.selectedSegmentIndex==0)||([mplayer isPlayingTrackedMusic]==0)) ) {*/
if (mOglViewIsHidden) {
m_oglView.hidden=YES;
} else {
if ((infoView.hidden==YES)&&(playlistView.hidden==YES)) {
if (m_oglView.hidden) {
viewTapHelpInfo=0;//255;
viewTapHelpShow=0;//1; //display info panel upon activation
}
m_oglView.hidden=NO;
}
}
}
- (IBAction)changeLoopMode {
mLoopMode++;
if (mLoopMode==3) mLoopMode=0;
switch (mLoopMode) {
case 0:
buttonLoopList.hidden=NO;
buttonLoopListSel.hidden=YES;
buttonLoopTitleSel.hidden=YES;
break;
case 1:
buttonLoopList.hidden=YES;
buttonLoopListSel.hidden=NO;
buttonLoopTitleSel.hidden=YES;
break;
case 2:
buttonLoopList.hidden=YES;
buttonLoopListSel.hidden=YES;
buttonLoopTitleSel.hidden=NO;
break;
}
}
- (IBAction)shuffle {
if (mShuffle) {
buttonShuffle.hidden=NO;
buttonShuffleSel.hidden=YES;
mShuffle=NO;
}
else {
buttonShuffle.hidden=YES;
buttonShuffleSel.hidden=NO;
mShuffle=YES;
}
}
- (void)oglViewSwitchFS {
oglViewFullscreen^=1;
oglViewFullscreenChanged=1;
[self shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientationHV];
}
- (IBAction)backPushed:(id)sender {
[[self navigationController] setNavigationBarHidden:NO animated:NO];
[[self navigationController] popViewControllerAnimated:YES];
}
- (IBAction)playPushed:(id)sender {
mPaused=0;
if (mIsPlaying) {
if (btnPlayCFlow.hidden==NO) {
btnPlayCFlow.hidden=YES;
btnPauseCFlow.hidden=NO;
}
self.pauseBarSub.hidden=YES;
self.playBarSub.hidden=YES;
self.pauseBar.hidden=YES;
self.playBar.hidden=YES;
if ( ([mplayer isArchive]&&([mplayer getArcEntriesCnt]>1)&&(mOnlyCurrentEntry==0))|| ([mplayer isMultiSongs]&&(mOnlyCurrentSubEntry==0))) {
self.pauseBarSub.hidden=NO;
} else {
self.pauseBar.hidden=NO;
}
[self updateBarPos];
[mplayer Pause:NO];
} else {
[self play_curEntry];
}
return;
}
- (IBAction)pausePushed:(id)sender {
mPaused=1;
if (mIsPlaying) {
if (btnPauseCFlow.hidden==NO) {
btnPauseCFlow.hidden=YES;
btnPlayCFlow.hidden=NO;
}
self.pauseBarSub.hidden=YES;
self.playBarSub.hidden=YES;
self.pauseBar.hidden=YES;
self.playBar.hidden=YES;
if ( ([mplayer isArchive]&&([mplayer getArcEntriesCnt]>1)&&(mOnlyCurrentEntry==0))|| ([mplayer isMultiSongs]&&(mOnlyCurrentSubEntry==0))) {
self.playBarSub.hidden=NO;
} else {
self.playBar.hidden=NO;
}
[self updateBarPos];
[mplayer Pause:YES];
}
return;
}
- (IBAction)sliderProgressModuleTest:(id)sender {
int slider_time;
sliderProgressModuleChanged=1;
sliderProgressModuleEdit=1;
if ([mplayer getSongLength]>0) slider_time=(int)(sliderProgressModule.value*(float)([mplayer getSongLength]-1));
labelTime.text=[NSString stringWithFormat:@"%.2d:%.2d", (slider_time/1000)/60,(slider_time/1000)%60];
if ([mplayer getSongLength]>0) labelModuleLength.text=[NSString stringWithFormat:@"-%.2d:%.2d", (([mplayer getSongLength]-slider_time)/1000)/60,(([mplayer getSongLength]-slider_time)/1000)%60];
return;
}
- (IBAction)sliderProgressModuleValueChanged:(id)sender {
int curTime;
if ([mplayer getSongLength]>0) curTime=(int)(sliderProgressModule.value*(float)([mplayer getSongLength]-1));
[mplayer Seek:curTime];
labelTime.text=[NSString stringWithFormat:@"%.2d:%.2d", ([mplayer getCurrentTime]/1000)/60,([mplayer getCurrentTime]/1000)%60];
if ([mplayer getSongLength]>0) labelModuleLength.text=[NSString stringWithFormat:@"-%.2d:%.2d", (([mplayer getSongLength]-[mplayer getCurrentTime])/1000)/60,(([mplayer getSongLength]-[mplayer getCurrentTime])/1000)%60];
sliderProgressModuleChanged=0;
sliderProgressModuleEdit=0;
return;
}
//define the targetmethod
-(void) updateInfos: (NSTimer *) theTimer {
int itime=[mplayer getCurrentTime];
if (mSendStatTimer) {
mSendStatTimer--;
if (mSendStatTimer==0) {
short int playcount;
DBHelper::getFileStatsDBmod(mPlaylist[mPlaylist_pos].mPlaylistFilename,mPlaylist[mPlaylist_pos].mPlaylistFilepath,&playcount,&mRating);
[GoogleAppHelper SendStatistics:mPlaylist[mPlaylist_pos].mPlaylistFilename path:mPlaylist[mPlaylist_pos].mPlaylistFilepath rating:mRating playcount:playcount country:located_country city:located_city longitude:located_lon latitude:located_lat];
}
}
int mpl_upd=[mplayer shouldUpdateInfos];
if (mpl_upd||mShouldUpdateInfos) {
if ((mpl_upd!=3)||(mShouldUpdateInfos)) {
short int playcount=0;
NSString *fileName=mPlaylist[mPlaylist_pos].mPlaylistFilename;
NSString *filePath=mPlaylist[mPlaylist_pos].mPlaylistFilepath;
DBHelper::getFileStatsDBmod(fileName,filePath,&playcount,&mRating);
DBHelper::updateFileStatsDBmod(fileName,filePath,playcount,mRating,[mplayer getSongLength],mplayer.numChannels,(mOnlyCurrentEntry==0?([mplayer isArchive]?-[mplayer getArcEntriesCnt]:mplayer.mod_subsongs):-1));
mShouldUpdateInfos=0;
}
if (mpl_upd>=2) {
if (mpl_upd==2) {
if (sc_titleFilename.selectedSegmentIndex==0) {
labelModuleName.text=[NSString stringWithString:[mplayer getModName]];
lblCurrentSongCFlow.text=labelModuleName.text;
}
}
if (infoView.hidden==FALSE) textMessage.text=[NSString stringWithFormat:@"%@",[mplayer getModMessage]];
if (mpl_upd==3) {
if (infoView.hidden==FALSE) [textMessage scrollRangeToVisible:NSMakeRange([textMessage.text length], 0)];
}
}
[mplayer setInfosUpdated];
if ((mplayer.mod_subsongs>1)&&(mOnlyCurrentSubEntry==0)) {
int mpl_arcCnt=[mplayer getArcEntriesCnt];
if (mpl_arcCnt&&(mOnlyCurrentEntry==0)) {
playlistPos.text=[NSString stringWithFormat:@"%d of %d/arc %d of %d/sub %d(%d,%d)",mPlaylist_pos+1,mPlaylist_size,
[mplayer getArcIndex]+1,mpl_arcCnt,
mplayer.mod_currentsub,mplayer.mod_minsub,mplayer.mod_maxsub];
} else {
playlistPos.text=[NSString stringWithFormat:@"%d of %d/sub %d(%d,%d)",mPlaylist_pos+1,mPlaylist_size,mplayer.mod_currentsub,mplayer.mod_minsub,mplayer.mod_maxsub];
}
[pvSubSongSel reloadAllComponents];
if (btnShowSubSong.hidden==true) {
btnShowSubSong.hidden=false;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelay:0.0];
[UIView setAnimationDuration:0.70];
// [UIView setAnimationDelegate:self];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.btnShowSubSong cache:YES];
[UIView commitAnimations];
}
} else {
int mpl_arcCnt=[mplayer getArcEntriesCnt];
if (mpl_arcCnt&&(mOnlyCurrentEntry==0)) {
playlistPos.text=[NSString stringWithFormat:@"%d of %d/arc %d of %d",mPlaylist_pos+1,mPlaylist_size,
[mplayer getArcIndex]+1,mpl_arcCnt];
} else playlistPos.text=[NSString stringWithFormat:@"%d of %d",mPlaylist_pos+1,mPlaylist_size];
btnShowSubSong.hidden=true;
}
self.pauseBarSub.hidden=YES;
self.playBarSub.hidden=YES;
self.pauseBar.hidden=YES;
self.playBar.hidden=YES;
if (mIsPlaying&& (mplayer.bGlobalAudioPause==0) ) {
if ( ([mplayer isArchive]&&([mplayer getArcEntriesCnt]>1)&&(mOnlyCurrentEntry==0))|| ([mplayer isMultiSongs]&&(mOnlyCurrentSubEntry==0))) self.pauseBarSub.hidden=NO;
else self.pauseBar.hidden=NO;
mPaused=0;
} else {
if ( ([mplayer isArchive]&&([mplayer getArcEntriesCnt]>1)&&(mOnlyCurrentEntry==0))|| ([mplayer isMultiSongs]&&(mOnlyCurrentSubEntry==0))) self.playBarSub.hidden=NO;
else self.playBar.hidden=NO;
mPaused=1;
}
[self updateBarPos];
if ([mplayer getSongLength]<0) {
labelModuleLength.text=@"--:--";
sliderProgressModule.enabled=FALSE;
} else sliderProgressModule.enabled=TRUE;
}
if (([mplayer getSongLength]>0)&&(itime>[mplayer getSongLength])) // if gone too far, limit
itime=[mplayer getSongLength];
if (!sliderProgressModuleEdit) {
labelTime.text=[NSString stringWithFormat:@"%.2d:%.2d", ([mplayer getCurrentTime]/1000)/60,([mplayer getCurrentTime]/1000)%60];
if ([mplayer getSongLength]>0) {
lblTimeFCflow.text=[NSString stringWithFormat:@"%.2d:%.2d - %.2d:%.2d", ([mplayer getCurrentTime]/1000)/60,([mplayer getCurrentTime]/1000)%60,([mplayer getSongLength]/1000)/60,([mplayer getSongLength]/1000)%60];
} else {
lblTimeFCflow.text=[NSString stringWithFormat:@"%.2d:%.2d", ([mplayer getCurrentTime]/1000)/60,([mplayer getCurrentTime]/1000)%60];
}
if ([mplayer getSongLength]>0) {
labelModuleLength.text=[NSString stringWithFormat:@"-%.2d:%.2d", (([mplayer getSongLength]-itime)/1000)/60,(([mplayer getSongLength]-itime)/1000)%60];
sliderProgressModule.value=(float)(itime)/(float)([mplayer getSongLength]);
}
if ((mMoveStartChanLeft)&&(startChan>0)) startChan--;
if ((mMoveStartChanRight)&&(startChan<(mplayer.numChannels-visibleChan))) startChan++;
}
int seekinprogress=[mplayer isSeeking];
if (seekinprogress) {
labelSeeking.hidden=FALSE;
if (seekinprogress>0) labelSeeking.text=[NSString stringWithFormat:NSLocalizedString(@"Seeking %d%%",@""),seekinprogress];
else labelSeeking.text=NSLocalizedString(@"Seeking",@"");
} else labelSeeking.hidden=TRUE;
if ((mPaused==0)&&(mplayer.bGlobalAudioPause==2)&&[mplayer isEndReached]) {//mod ended
//have to update the pause button
mSendStatTimer=0;
mIsPlaying=FALSE;
mPaused=1;
self.pauseBarSub.hidden=YES;
self.playBarSub.hidden=YES;
self.pauseBar.hidden=YES;
self.playBar.hidden=YES;
if ( ([mplayer isArchive]&&([mplayer getArcEntriesCnt]>1)&&(mOnlyCurrentEntry==0))|| ([mplayer isMultiSongs]&&(mOnlyCurrentSubEntry==0))) self.playBarSub.hidden=NO;
else self.playBar.hidden=NO;
[self updateBarPos];
//and go to next entry if playlist
if ((mLoopMode==2)||(mplayer.mLoopMode==1)) [self play_curEntry];
else {
if ([mplayer isArchive]&&([mplayer getArcEntriesCnt]>1)&&([mplayer getArcIndex]<[mplayer getArcEntriesCnt]-1)&&(mOnlyCurrentEntry==0)) {
[mplayer selectNextArcEntry];
[self performSelectorInBackground:@selector(showWaiting) withObject:nil];
[self play_loadArchiveModule];
[self performSelectorInBackground:@selector(hideWaiting) withObject:nil];
} else [self play_nextEntry];
}
return;
} else {
// NSLog(@"waiting : %d %d",mplayer.bGlobalAudioPause,[mplayer isEndReached]);
}
if ( (mPaused==0)&&(mplayer.bGlobalAudioPause==0)&&(segcont_randFx.selectedSegmentIndex==1) ) {
if (mRandomFXCpt) {
mRandomFXCpt--;
mRandomFXCptRev++;
if ((mRandomFXCptRev>ALLOW_CHANGE_ON_BEAT_TIME*5)&&((arc4random()&3)>1) ) {
for (int i=0;i<SPECTRUM_BANDS;i++) {
if (real_beatDetectedL[i]) {mRandomFXCpt=0;break;}
if (real_beatDetectedR[i]) {mRandomFXCpt=0;break;}
}
}
}
if (mRandomFXCpt==0) {
mRandomFXCpt=MIN_RANDFX_TIME*5+arc4random()%(5*MAX_RANDFX_TIME); //Min is 10 seconds Max is 60seconds
mRandomFXCptRev=0;
segcont_spectrum.selectedSegmentIndex=0;
segcont_oscillo.selectedSegmentIndex=0;
segcont_fx1.selectedSegmentIndex=0;
segcont_fx2.selectedSegmentIndex=0;
segcont_fx3.selectedSegmentIndex=0;
segcont_fx4.selectedSegmentIndex=0;
segcont_fx5.selectedSegmentIndex=0;
segcont_FxBeat.selectedSegmentIndex=0;
switch (arc4random()%19) {
case 0:
segcont_spectrum.selectedSegmentIndex=(arc4random()&1)+1;
break;
case 1:
segcont_oscillo.selectedSegmentIndex=(arc4random()&1)+1;
break;
case 2:
segcont_FxBeat.selectedSegmentIndex=1;
break;
case 3:
segcont_fx1.selectedSegmentIndex=1;
break;
case 4:
segcont_fx2.selectedSegmentIndex=(arc4random()%3)+1;
break;
case 5:
segcont_fx3.selectedSegmentIndex=(arc4random()%3)+1;
break;
case 6:
segcont_FxBeat.selectedSegmentIndex=1;
segcont_oscillo.selectedSegmentIndex=(arc4random()&1)+1;
break;
case 7:
segcont_FxBeat.selectedSegmentIndex=1;
segcont_spectrum.selectedSegmentIndex=(arc4random()&1)+1;
break;
case 8:
segcont_FxBeat.selectedSegmentIndex=1;
segcont_fx1.selectedSegmentIndex=1;
break;
case 9:
segcont_FxBeat.selectedSegmentIndex=1;
segcont_fx2.selectedSegmentIndex=(arc4random()%3)+1;
break;
case 10:
segcont_FxBeat.selectedSegmentIndex=1;
segcont_fx3.selectedSegmentIndex=(arc4random()%3)+1;
break;
case 11:
segcont_oscillo.selectedSegmentIndex=(arc4random()&1)+1;
segcont_spectrum.selectedSegmentIndex=(arc4random()&1)+1;
break;
case 12:
segcont_oscillo.selectedSegmentIndex=(arc4random()&1)+1;
segcont_fx2.selectedSegmentIndex=(arc4random()%3)+1;
break;
case 13:
segcont_oscillo.selectedSegmentIndex=(arc4random()&1)+1;
segcont_fx3.selectedSegmentIndex=(arc4random()%3)+1;
break;
case 14:
segcont_oscillo.selectedSegmentIndex=(arc4random()&1)+1;
segcont_fx1.selectedSegmentIndex=1;
break;
case 15:
segcont_FxBeat.selectedSegmentIndex=1;
segcont_oscillo.selectedSegmentIndex=(arc4random()&1)+1;
segcont_spectrum.selectedSegmentIndex=(arc4random()&1)+1;
break;
case 16:
segcont_FxBeat.selectedSegmentIndex=1;
segcont_oscillo.selectedSegmentIndex=(arc4random()&1)+1;
segcont_fx1.selectedSegmentIndex=1;
break;
case 17:
segcont_FxBeat.selectedSegmentIndex=1;
segcont_oscillo.selectedSegmentIndex=(arc4random()&1)+1;
segcont_fx2.selectedSegmentIndex=(arc4random()%3)+1;
break;
case 18:
segcont_FxBeat.selectedSegmentIndex=1;
segcont_oscillo.selectedSegmentIndex=(arc4random()&1)+1;
segcont_fx3.selectedSegmentIndex=(arc4random()%3)+1;
break;
}
}
}
return;
}
int qsort_ComparePlEntries(const void *entryA, const void *entryB) {
NSString *strA,*strB;
NSComparisonResult res;
strA=((t_plPlaylist_entry*)entryA)->mPlaylistFilename;
strB=((t_plPlaylist_entry*)entryB)->mPlaylistFilename;
res=[strA localizedCaseInsensitiveCompare:strB];
if (res==NSOrderedAscending) return -1;
if (res==NSOrderedSame) return 0;
return 1; //NSOrderedDescending
}
int qsort_ComparePlEntriesRev(const void *entryA, const void *entryB) {
NSString *strA,*strB;
NSComparisonResult res;
strA=((t_plPlaylist_entry*)entryA)->mPlaylistFilename;
strB=((t_plPlaylist_entry*)entryB)->mPlaylistFilename;
res=[strB localizedCaseInsensitiveCompare:strA];
if (res==NSOrderedAscending) return -1;
if (res==NSOrderedSame) return 0;
return 1; //NSOrderedDescending
}
-(IBAction) plSortAZ {
btnSortPlAZ.hidden=YES;
btnSortPlZA.hidden=NO;
coverflow_needredraw=1;
NSString *curEntryPath=mPlaylist[mPlaylist_pos].mPlaylistFilepath;
qsort(mPlaylist,mPlaylist_size,sizeof(t_plPlaylist_entry),qsort_ComparePlEntries);
mPlaylist_pos=0;
while (mPlaylist[mPlaylist_pos].mPlaylistFilepath!=curEntryPath) {
mPlaylist_pos++;
if (mPlaylist_pos>=mPlaylist_size) {mPlaylist_pos=0; break;}
}
[playlistTabView reloadData];
NSIndexPath *myindex=[[NSIndexPath alloc] initWithIndex:0];
[self.playlistTabView selectRowAtIndexPath:[myindex indexPathByAddingIndex:mPlaylist_pos] animated:TRUE scrollPosition:UITableViewScrollPositionMiddle];
[myindex autorelease];
mShouldUpdateInfos=1;
}
-(IBAction) plSortZA {
btnSortPlAZ.hidden=NO;
btnSortPlZA.hidden=YES;
coverflow_needredraw=1;
NSString *curEntryPath=mPlaylist[mPlaylist_pos].mPlaylistFilepath;
qsort(mPlaylist,mPlaylist_size,sizeof(t_plPlaylist_entry),qsort_ComparePlEntriesRev);
mPlaylist_pos=0;
while (mPlaylist[mPlaylist_pos].mPlaylistFilepath!=curEntryPath) {
mPlaylist_pos++;
if (mPlaylist_pos>=mPlaylist_size) {mPlaylist_pos=0; break;}
}
[playlistTabView reloadData];
NSIndexPath *myindex=[[NSIndexPath alloc] initWithIndex:0];
[self.playlistTabView selectRowAtIndexPath:[myindex indexPathByAddingIndex:mPlaylist_pos] animated:TRUE scrollPosition:UITableViewScrollPositionMiddle];
[myindex autorelease];
mShouldUpdateInfos=1;
}
-(IBAction) plShuffle {
int fromr,tor;
t_plPlaylist_entry tmp;
if (mPlaylist_size<2) return;
coverflow_needredraw=1;
for (int i=0;i<mPlaylist_size*2;i++) {
fromr=arc4random()%(mPlaylist_size);
do {
tor=arc4random()%(mPlaylist_size);
} while (tor==fromr);
tmp=mPlaylist[fromr];
mPlaylist[fromr]=mPlaylist[tor];
mPlaylist[tor]=tmp;
if (mPlaylist_pos==fromr) mPlaylist_pos=tor;
else if (mPlaylist_pos==tor) mPlaylist_pos=fromr;
}
[playlistTabView reloadData];
NSIndexPath *myindex=[[NSIndexPath alloc] initWithIndex:0];
[self.playlistTabView selectRowAtIndexPath:[myindex indexPathByAddingIndex:mPlaylist_pos] animated:TRUE scrollPosition:UITableViewScrollPositionMiddle];
[myindex autorelease];
mShouldUpdateInfos=1;
}
-(IBAction) plClear {
coverflow_needredraw=1;
if (mPlaylist_size) { //ensure playlist is not empty
for (int i=mPlaylist_size-1;i>=0;i--) if (i!=mPlaylist_pos) {
[mPlaylist[i].mPlaylistFilename autorelease];
[mPlaylist[i].mPlaylistFilepath autorelease];
}
mPlaylist[0]=mPlaylist[mPlaylist_pos];
mPlaylist_size=1;
mPlaylist_pos=0;
mShouldUpdateInfos=1;
}
[playlistTabView reloadData];
NSIndexPath *myindex=[[NSIndexPath alloc] initWithIndex:0];
[self.playlistTabView selectRowAtIndexPath:[myindex indexPathByAddingIndex:mPlaylist_pos] animated:TRUE scrollPosition:UITableViewScrollPositionMiddle];
[myindex autorelease];
}
-(IBAction) plEdit {
[playlistTabView setEditing:YES];
btnPlEdit.hidden=YES;
btnPlOk.hidden=NO;
coverflow_needredraw=1;
}
-(IBAction) plDone {
[playlistTabView setEditing:NO];
btnPlEdit.hidden=NO;
btnPlOk.hidden=YES;
NSIndexPath *myindex=[[NSIndexPath alloc] initWithIndex:0];
[self.playlistTabView selectRowAtIndexPath:[myindex indexPathByAddingIndex:mPlaylist_pos] animated:TRUE scrollPosition:UITableViewScrollPositionMiddle];
[myindex autorelease];
}
- (IBAction)showPlaylist {
if (!mPlaylist_size) return;
if (playlistView.hidden==NO) {
[self hidePlaylist];
return;
}
if (infoView.hidden==NO) {
mPlWasView=infoView;
mPlWasViewHidden=infoView.hidden;
} else {
mPlWasView=m_oglView;
mPlWasViewHidden=m_oglView.hidden;
}
btnPlOk.hidden=YES;
btnPlEdit.hidden=NO;
btnSortPlAZ.hidden=NO;
btnSortPlZA.hidden=YES;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.70];
// [UIView setAnimationDelegate:self];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:mPlWasView cache:YES];
mPlWasView.hidden=YES;
[UIView commitAnimations];
if (plIsFullscreen) {
mainView.hidden=YES;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.70];
// [UIView setAnimationDelegate:self];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:mainView cache:YES];
[UIView commitAnimations];
}
self.playlistView.hidden=NO;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.70];
// [UIView setAnimationDelegate:self];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.playlistView cache:YES];
[UIView commitAnimations];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelay:0.70];
[UIView setAnimationDuration:0.70];
// [UIView setAnimationDelegate:self];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.backPlaylist cache:YES];
[UIView commitAnimations];
NSIndexPath *myindex=[[NSIndexPath alloc] initWithIndex:0];
[self.playlistTabView selectRowAtIndexPath:[myindex indexPathByAddingIndex:mPlaylist_pos] animated:TRUE scrollPosition:UITableViewScrollPositionMiddle];
[myindex autorelease];
}
- (IBAction)hidePlaylist {
if ((mPlWasView==infoView)&&(mInWasView==playlistView)) mPlWasView=m_oglView; //avoid cycling between view
if (mPlWasView==m_oglView) { //if ogl view was selected, check if it should be hidden
/*if ((segcont_fx1.selectedSegmentIndex)||
(segcont_fx2.selectedSegmentIndex)||
(segcont_fx3.selectedSegmentIndex)||
(segcont_FxBeat.selectedSegmentIndex)||
(segcont_spectrum.selectedSegmentIndex)||
(segcont_oscillo.selectedSegmentIndex)||
((segcont_shownote.selectedSegmentIndex)&&([mplayer isPlayingTrackedMusic])) ) {
mPlWasViewHidden=NO;
} else mPlWasViewHidden=YES;*/
if (mOglViewIsHidden) mPlWasViewHidden=YES;
else mPlWasViewHidden=NO;
}
if (btnPlEdit.hidden) [self plDone];
NSIndexPath *myindex=[[NSIndexPath alloc] initWithIndex:0];
[self.playlistTabView selectRowAtIndexPath:[myindex indexPathByAddingIndex:mPlaylist_pos] animated:TRUE scrollPosition:UITableViewScrollPositionMiddle];
[myindex autorelease];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.70];
// [UIView setAnimationDelegate:self];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.playlistView cache:YES];
self.playlistView.hidden=YES;
[UIView commitAnimations];
if (!mPlWasViewHidden) {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.70];
// [UIView setAnimationDelegate:self];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:mPlWasView cache:YES];
mPlWasView.hidden=NO;
if (plIsFullscreen) {
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:mainView cache:YES];
mainView.hidden=NO;
}
[UIView commitAnimations];
} else if (plIsFullscreen) {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.70];
// [UIView setAnimationDelegate:self];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:mainView cache:YES];
mainView.hidden=NO;
[UIView commitAnimations];
}
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelay:0.70];
[UIView setAnimationDuration:0.70];
// [UIView setAnimationDelegate:self];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.infoButton cache:YES];
[UIView commitAnimations];
if (btnShowSubSong.hidden==false) {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelay:0.75];
[UIView setAnimationDuration:0.70];
// [UIView setAnimationDelegate:self];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.btnShowSubSong cache:YES];
[UIView commitAnimations];
}
if (btnShowArcList.hidden==false) {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelay:0.75];
[UIView setAnimationDuration:0.70];
// [UIView setAnimationDelegate:self];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.btnShowArcList cache:YES];
[UIView commitAnimations];
}
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelay:1.00];
[UIView setAnimationDuration:0.70];
// [UIView setAnimationDelegate:self];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationItem.rightBarButtonItem.customView cache:YES];
[UIView commitAnimations];
}
- (IBAction)infoFullscreen {
infoIsFullscreen=1;
infoZoom.hidden=YES;
infoUnzoom.hidden=NO;
[self shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientationHV];
}
- (IBAction)infoNormal {
infoIsFullscreen=0;
infoZoom.hidden=NO;
infoUnzoom.hidden=YES;
mainView.hidden=NO;
[self shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientationHV];
}
- (IBAction)plFullscreen {
plIsFullscreen=1;
plZoom.hidden=YES;
plUnzoom.hidden=NO;
[self shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientationHV];
}
- (IBAction)plNormal {
plIsFullscreen=0;
plZoom.hidden=NO;
plUnzoom.hidden=YES;
mainView.hidden=NO;
[self shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orientationHV];
}
- (IBAction)showInfo {
if (infoView.hidden==NO) {
[self hideInfo];
return;
}
textMessage.text=[NSString stringWithFormat:@"%@",[mplayer getModMessage]];
if (playlistView.hidden==NO) {
mInWasView=playlistView;
mInWasViewHidden=playlistView.hidden;
} else {
mInWasView=m_oglView;
mInWasViewHidden=m_oglView.hidden;
}
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.70];
// [UIView setAnimationDelegate:self];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:mInWasView cache:YES];
mInWasView.hidden=YES;
[UIView commitAnimations];
if (infoIsFullscreen) {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.70];
// [UIView setAnimationDelegate:self];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:mainView cache:YES];
mainView.hidden=YES;
[UIView commitAnimations];
}
infoView.hidden=NO;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.70];
// [UIView setAnimationDelegate:self];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:infoView cache:YES];
[UIView commitAnimations];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelay:0.70];
[UIView setAnimationDuration:0.70];
// [UIView setAnimationDelegate:self];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:backInfo cache:YES];
[UIView commitAnimations];
}
- (IBAction)hideInfo {
if ((mPlWasView==infoView)&&(mInWasView==playlistView)) mInWasView=m_oglView; //avoid cycling between view
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.70];
// [UIView setAnimationDelegate:self];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:infoView cache:YES];
infoView.hidden=YES;
[UIView commitAnimations];
if (mInWasView==m_oglView) { //if ogl view was selected, check if it should be hidden
if (mOglViewIsHidden) mInWasViewHidden=YES;
else mInWasViewHidden=NO;
}
if (!mInWasViewHidden) {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.70];
// [UIView setAnimationDelegate:self];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:mInWasView cache:YES];
mInWasView.hidden=NO;
if (infoIsFullscreen) {
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:mainView cache:YES];
mainView.hidden=NO;
}
[UIView commitAnimations];
} else if (infoIsFullscreen) {
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.70];
// [UIView setAnimationDelegate:self];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:mainView cache:YES];
mainView.hidden=NO;
[UIView commitAnimations];
}
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelay:0.70];
[UIView setAnimationDuration:0.70];
// [UIView setAnimationDelegate:self];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:infoButton cache:YES];
[UIView commitAnimations];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelay:1.00];
[UIView setAnimationDuration:0.70];
// [UIView setAnimationDelegate:self];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationItem.rightBarButtonItem.customView cache:YES];
[UIView commitAnimations];
}
- (IBAction)playPrevSub {
//if archive and no subsongs => change archive index
if ([mplayer isArchive]&&(mplayer.mod_subsongs==1)) {
[mplayer selectPrevArcEntry];
[self performSelectorInBackground:@selector(showWaiting) withObject:nil];
[self play_loadArchiveModule];
[self performSelectorInBackground:@selector(hideWaiting) withObject:nil];
} else [mplayer playPrevSub];
}
- (IBAction)playNextSub {
//if archive and no subsongs => change archive index
if ([mplayer isArchive]&&(mplayer.mod_subsongs==1)) {
[mplayer selectNextArcEntry];
[self performSelectorInBackground:@selector(showWaiting) withObject:nil];
[self play_loadArchiveModule];
[self performSelectorInBackground:@selector(hideWaiting) withObject:nil];
} else [mplayer playNextSub];
}
-(void) longPressNextSubArc:(UIGestureRecognizer *)gestureRecognizer {
if ([gestureRecognizer state]==UIGestureRecognizerStateBegan) {
if ([mplayer isArchive]) {
[mplayer selectNextArcEntry];
[self performSelectorInBackground:@selector(showWaiting) withObject:nil];
[self play_loadArchiveModule];
[self performSelectorInBackground:@selector(hideWaiting) withObject:nil];
}
}
}
-(void) longPressPrevSubArc:(UIGestureRecognizer *)gestureRecognizer {
if ([gestureRecognizer state]==UIGestureRecognizerStateBegan) {
if ([mplayer isArchive]) {
[mplayer selectPrevArcEntry];
[self performSelectorInBackground:@selector(showWaiting) withObject:nil];
[self play_loadArchiveModule];
[self performSelectorInBackground:@selector(hideWaiting) withObject:nil];
}
}
}
- (IBAction)playNext {
[self play_nextEntry];
}
- (IBAction)playPrev {
if ([mplayer getCurrentTime]>=MIN_DELAY_PREV_ENTRY) {//if more than MIN_DELAY_PREV_ENTRY milliseconds are elapsed, restart current track
[self play_curEntry];
} else [self play_prevEntry];
}
-(BOOL)play_curEntry {
NSString *fileName;
NSString *filePath;
mIsPlaying=FALSE;
if (!mPlaylist_size) return FALSE;
if (mPlaylist_pos>mPlaylist_size-1) mPlaylist_pos=0;
fileName=mPlaylist[mPlaylist_pos].mPlaylistFilename;
filePath=mPlaylist[mPlaylist_pos].mPlaylistFilepath;
mPlaylist[mPlaylist_pos].mPlaylistCount++;
if (self.playlistView.hidden==FALSE) {
NSIndexPath *myindex=[[NSIndexPath alloc] initWithIndex:0];
[self.playlistTabView selectRowAtIndexPath:[myindex indexPathByAddingIndex:mPlaylist_pos] animated:TRUE scrollPosition:UITableViewScrollPositionMiddle];
[myindex autorelease];
}
mShouldUpdateInfos=1;
[self performSelectorInBackground:@selector(showWaiting) withObject:nil];
if ([self play_module:filePath fname:fileName]==FALSE) {
[self remove_from_playlist:mPlaylist_pos];
if ((alertCannotPlay_displayed==0)&&(mLoadIssueMessage)) {
NSString *alertMsg;
alertCannotPlay_displayed=1;
if (mplayer_error_msg[0]) alertMsg=[NSString stringWithFormat:@"%@\n%s", NSLocalizedString(@"File cannot be played. Skipping to next playable file.",@""),mplayer_error_msg];
else alertMsg=NSLocalizedString(@"File cannot be played. Skipping to next playable file.",@"");
UIAlertView *alertCannotPlay = [[[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Warning",@"")
message:alertMsg delegate:self cancelButtonTitle:NSLocalizedString(@"Close",@"") otherButtonTitles:nil] autorelease];
if (alertCannotPlay) [alertCannotPlay show];
[self play_curEntry];
} else [self play_curEntry];
//remove
[self performSelectorInBackground:@selector(hideWaiting) withObject:nil];
return FALSE;
}
[self performSelectorInBackground:@selector(hideWaiting) withObject:nil];
return TRUE;
}
-(void)play_prevEntry {
if (mShuffle) {
int i;
int minval;
minval=mPlaylist[0].mPlaylistCount;
for (i=0;i<mPlaylist_size;i++) if (mPlaylist[i].mPlaylistCount<minval) minval=mPlaylist[i].mPlaylistCount;
mPlaylist_pos=arc4random()%(mPlaylist_size);
i=0;
while ((i<mPlaylist_size)&&(mPlaylist[mPlaylist_pos].mPlaylistCount>minval)) {
i++;
mPlaylist_pos++; if (mPlaylist_pos>=mPlaylist_size) mPlaylist_pos=0;
}
[self play_curEntry];
} else {
if (mPlaylist_pos>0) mPlaylist_pos--;
else if (mLoopMode==1) mPlaylist_pos=mPlaylist_size-1;
[self play_curEntry];
}
}
-(void)play_nextEntry {
if (mShuffle) {
int i;
int minval;
minval=mPlaylist[0].mPlaylistCount;
for (i=0;i<mPlaylist_size;i++) if (mPlaylist[i].mPlaylistCount<minval) minval=mPlaylist[i].mPlaylistCount;
mPlaylist_pos=arc4random()%(mPlaylist_size);
i=0;
while ((i<mPlaylist_size)&&(mPlaylist[mPlaylist_pos].mPlaylistCount>minval)) {
i++;
mPlaylist_pos++; if (mPlaylist_pos>=mPlaylist_size) mPlaylist_pos=0;
}
[self play_curEntry];
} else if (mPlaylist_pos<mPlaylist_size-1) {
mPlaylist_pos++;
[self play_curEntry];
} else if (mLoopMode==1) {
mPlaylist_pos=0;
[self play_curEntry];
}
}
-(void)play_randomEntry {
}
-(void)play_listmodules:(NSArray *)array start_index:(int)index path:(NSArray *)arrayFilepaths {
int limitPl=0;
mRestart=0;
mRestart_sub=0;
mRestart_arc=0;
mPlayingPosRestart=0;
if ([array count]>=MAX_PL_ENTRIES) {
NSString *msg_str=[NSString stringWithFormat:NSLocalizedString(@"Too much entries! Playlist will be limited to %d first entries.",@""),MAX_PL_ENTRIES];
UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Warning",@"") message:msg_str delegate:self cancelButtonTitle:NSLocalizedString(@"Close",@"") otherButtonTitles:nil] autorelease];
[alert show];
limitPl=1;
// return;
}
if (mPlaylist_size) {
for (int i=0;i<mPlaylist_size;i++) {
[mPlaylist[i].mPlaylistFilename autorelease];
[mPlaylist[i].mPlaylistFilepath autorelease];
}
}
mPlaylist_size=(limitPl?MAX_PL_ENTRIES:[array count]);
for (int i=0;i<mPlaylist_size;i++) {
mPlaylist[i].mPlaylistFilename=[[NSString alloc] initWithString:[array objectAtIndex:i]];
mPlaylist[i].mPlaylistFilepath=[[NSString alloc] initWithString:[arrayFilepaths objectAtIndex:i]];
short int playcount=0;
signed char rating=0;
//DBHelper::getFileStatsDBmod(mPlaylist[i].mPlaylistFilename,mPlaylist[i].mPlaylistFilepath,&playcount,&rating);
mPlaylist[i].mPlaylistRating=-1;//rating;
mPlaylist[i].mPlaylistCount=0;
//[self checkAvailableCovers:i];
mPlaylist[i].cover_flag=-1;
}
coverflow_needredraw=1;
mPlaylist_pos=index;
if (mShuffle) {
int i;
int minval;
minval=mPlaylist[0].mPlaylistCount;
for (i=0;i<mPlaylist_size;i++) if (mPlaylist[i].mPlaylistCount<minval) minval=mPlaylist[i].mPlaylistCount;
mPlaylist_pos=arc4random()%(mPlaylist_size);
i=0;
while ((i<mPlaylist_size)&&(mPlaylist[mPlaylist_pos].mPlaylistCount>minval)) {
i++;
mPlaylist_pos++; if (mPlaylist_pos>=mPlaylist_size) mPlaylist_pos=0;
}
}
[playlistTabView reloadData];
[self play_curEntry];
}
-(void)play_listmodules:(NSArray *)array start_index:(int)index path:(NSArray *)arrayFilepaths ratings:(signed char*)ratings playcounts:(short int*)playcounts {
int limitPl=0;
mRestart=0;
mRestart_sub=0;
mRestart_arc=0;
mPlayingPosRestart=0;
if ([array count]>=MAX_PL_ENTRIES) {
NSString *msg_str=[NSString stringWithFormat:NSLocalizedString(@"Too much entries! Playlist will be limited to %d first entries.",@""),MAX_PL_ENTRIES];
UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Warning",@"") message:msg_str delegate:self cancelButtonTitle:NSLocalizedString(@"Close",@"") otherButtonTitles:nil] autorelease];
[alert show];
limitPl=1;
// return;
}
if (mPlaylist_size) {
for (int i=0;i<mPlaylist_size;i++) {
[mPlaylist[i].mPlaylistFilename autorelease];
[mPlaylist[i].mPlaylistFilepath autorelease];
}
}
mPlaylist_size=(limitPl?MAX_PL_ENTRIES:[array count]);
for (int i=0;i<mPlaylist_size;i++) {
mPlaylist[i].mPlaylistFilename=[[NSString alloc] initWithString:[array objectAtIndex:i]];
mPlaylist[i].mPlaylistFilepath=[[NSString alloc] initWithString:[arrayFilepaths objectAtIndex:i]];
mPlaylist[i].mPlaylistRating=ratings[i];
mPlaylist[i].mPlaylistCount=0;
// [self checkAvailableCovers:i];
mPlaylist[i].cover_flag=-1;
}
coverflow_needredraw=1;
mPlaylist_pos=(index>0?index:0);
if (mShuffle&&(index<0)) {
int i;
int minval;
minval=mPlaylist[0].mPlaylistCount;
for (i=0;i<mPlaylist_size;i++) if (mPlaylist[i].mPlaylistCount<minval) minval=mPlaylist[i].mPlaylistCount;
mPlaylist_pos=arc4random()%(mPlaylist_size);
i=0;
while ((i<mPlaylist_size)&&(mPlaylist[mPlaylist_pos].mPlaylistCount>minval)) {
i++;
mPlaylist_pos++; if (mPlaylist_pos>=mPlaylist_size) mPlaylist_pos=0;
}
}
[playlistTabView reloadData];
[self play_curEntry];
}
-(void)play_restart {
for (int i=0;i<mPlaylist_size;i++) {
mPlaylist[i].mPlaylistCount=0;
}
// DBHelper::getFilesStatsDBmod(mPlaylist,mPlaylist_size);
//[playlistTabView reloadData];
//if (segcont_resumeLaunch.selectedSegmentIndex==0) return;
mRestart=1;
if ([self play_curEntry]) {
// self.tabBarController.selectedViewController = self; //detailViewController;
}
}
-(int) add_to_playlist:(NSArray *)filePaths fileNames:(NSArray*)fileNames forcenoplay:(int)forcenoplay{
int added_pos;
int playLaunched=0;
int add_entries_nb=[fileNames count];
coverflow_needredraw=1;
// [self openPopup:@"Playlist updated"];
if (mPlaylist_size+add_entries_nb>=MAX_PL_ENTRIES) {
NSString *msg_str=[NSString stringWithFormat:NSLocalizedString(@"Too much entries! Playlist will be limited to %d first entries.",@""),MAX_PL_ENTRIES];
UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Warning",@"") message:msg_str delegate:self cancelButtonTitle:NSLocalizedString(@"Close",@"") otherButtonTitles:nil] autorelease];
[alert show];
return 0;
}
if (mPlaylist_size) { //already in a playlist : append to it
if (sc_EnqueueMode.selectedSegmentIndex==0) {
for (int i=mPlaylist_size-1;i>=0;i--) {
mPlaylist[i+add_entries_nb]=mPlaylist[i];
}
for (int i=0;i<add_entries_nb;i++) {
mPlaylist[i].mPlaylistFilename=[[NSString alloc] initWithString:[fileNames objectAtIndex:i]];
mPlaylist[i].mPlaylistFilepath=[[NSString alloc] initWithString:[filePaths objectAtIndex:i]];
mPlaylist[i].mPlaylistRating=-1;
//[self checkAvailableCovers:i];
mPlaylist[i].cover_flag=-1;
}
added_pos=0;
mPlaylist_pos+=add_entries_nb;
} else if ((sc_EnqueueMode.selectedSegmentIndex==1)&&(mPlaylist_pos<mPlaylist_size-1)) { //after current
for (int i=mPlaylist_size-1;i>mPlaylist_pos;i--) {
mPlaylist[i+add_entries_nb]=mPlaylist[i];
}
for (int i=0;i<add_entries_nb;i++) {
mPlaylist[i+mPlaylist_pos+1].mPlaylistFilename=[[NSString alloc] initWithString:[fileNames objectAtIndex:i]];
mPlaylist[i+mPlaylist_pos+1].mPlaylistFilepath=[[NSString alloc] initWithString:[filePaths objectAtIndex:i]];
mPlaylist[i+mPlaylist_pos+1].mPlaylistRating=-1;
//[self checkAvailableCovers:i+mPlaylist_pos+1];
mPlaylist[i+mPlaylist_pos+1].cover_flag=-1;
}
added_pos=mPlaylist_pos+1;
} else { //last
for (int i=0;i<add_entries_nb;i++) {
mPlaylist[i+mPlaylist_size].mPlaylistFilename=[[NSString alloc] initWithString:[fileNames objectAtIndex:i]];
mPlaylist[i+mPlaylist_size].mPlaylistFilepath=[[NSString alloc] initWithString:[filePaths objectAtIndex:i]];
mPlaylist[i+mPlaylist_size].mPlaylistRating=-1;
//[self checkAvailableCovers:i+mPlaylist_size];
mPlaylist[i+mPlaylist_size].cover_flag=-1;
}
added_pos=mPlaylist_size;
}
mPlaylist_size+=add_entries_nb;
//TODO To optimize
for (int i=added_pos;i<add_entries_nb;i++) {
mPlaylist[i].mPlaylistCount=0; //new entry
}
//DBHelper::getFilesStatsDBmod(&(mPlaylist[added_pos]),add_entries_nb);
[playlistTabView reloadData];
mShouldUpdateInfos=1;
} else { //create a new playlist with downloaded song
for (int i=0;i<add_entries_nb;i++) {
mPlaylist[i].mPlaylistFilename=[[NSString alloc] initWithString:[fileNames objectAtIndex:i]];
mPlaylist[i].mPlaylistFilepath=[[NSString alloc] initWithString:[filePaths objectAtIndex:i]];
mPlaylist[i].mPlaylistCount=0;
mPlaylist[i].mPlaylistRating=-1;
//[self checkAvailableCovers:i];
mPlaylist[i].cover_flag=-1;
}
mPlaylist_size=add_entries_nb;
//DBHelper::getFilesStatsDBmod(mPlaylist,mPlaylist_size);
mPlaylist_pos=0;
added_pos=0;
[playlistTabView reloadData];
[self play_curEntry];
playLaunched=1;
}
if ((playLaunched==0)&&(!forcenoplay)&&(sc_DefaultAction.selectedSegmentIndex==2)) {//Enqueue & play
mPlaylist_pos=added_pos;
[self play_curEntry];
playLaunched=1;
}
NSIndexPath *myindex=[[NSIndexPath alloc] initWithIndex:0];
if (mPlaylist_size) [self.playlistTabView selectRowAtIndexPath:[myindex indexPathByAddingIndex:mPlaylist_pos] animated:TRUE scrollPosition:UITableViewScrollPositionMiddle];
[myindex autorelease];
return playLaunched;
}
-(int) add_to_playlist:(NSString*)filePath fileName:(NSString*)fileName forcenoplay:(int)forcenoplay{
int added_pos;
int playLaunched=0;
short int playcount=0;
signed char rating=0;
if (mPlaylist_size>=MAX_PL_ENTRIES) {
NSString *msg_str=[NSString stringWithFormat:NSLocalizedString(@"Too much entries! Playlist will be limited to %d first entries.",@""),MAX_PL_ENTRIES];
UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Warning",@"") message:msg_str delegate:self cancelButtonTitle:NSLocalizedString(@"Close",@"") otherButtonTitles:nil] autorelease];
[alert show];
return 0;
}
coverflow_needredraw=1;
if (mPlaylist_size) { //already in a playlist : append to it
if (sc_EnqueueMode.selectedSegmentIndex==0) {
for (int i=mPlaylist_size-1;i>=0;i--) {
mPlaylist[i+1]=mPlaylist[i];
}
mPlaylist[0].mPlaylistFilename=[[NSString alloc] initWithString:fileName];
mPlaylist[0].mPlaylistFilepath=[[NSString alloc] initWithString:filePath];
//[self checkAvailableCovers:0];
mPlaylist[0].cover_flag=-1;
added_pos=0;
mPlaylist_pos++;
} else if ((sc_EnqueueMode.selectedSegmentIndex==1)&&(mPlaylist_pos<mPlaylist_size-1)) { //after current
for (int i=mPlaylist_size-1;i>mPlaylist_pos;i--) {
mPlaylist[i+1]=mPlaylist[i];
}
mPlaylist[mPlaylist_pos+1].mPlaylistFilename=[[NSString alloc] initWithString:fileName];
mPlaylist[mPlaylist_pos+1].mPlaylistFilepath=[[NSString alloc] initWithString:filePath];
//[self checkAvailableCovers:mPlaylist_pos+1];
mPlaylist[mPlaylist_pos+1].cover_flag=-1;
added_pos=mPlaylist_pos+1;
} else { //last
mPlaylist[mPlaylist_size].mPlaylistFilename=[[NSString alloc] initWithString:fileName];
mPlaylist[mPlaylist_size].mPlaylistFilepath=[[NSString alloc] initWithString:filePath];
// [self checkAvailableCovers:mPlaylist_size];
mPlaylist[mPlaylist_size].cover_flag=-1;
added_pos=mPlaylist_size;
}
mPlaylist_size++;
//TODO To optimize
mPlaylist[added_pos].mPlaylistCount=0;
rating=0;
DBHelper::getFileStatsDBmod(mPlaylist[added_pos].mPlaylistFilename,mPlaylist[added_pos].mPlaylistFilepath,&playcount,&rating);
mPlaylist[added_pos].mPlaylistRating=rating;
[playlistTabView reloadData];
mShouldUpdateInfos=1;
} else { //create a new playlist with downloaded song
mPlaylist[0].mPlaylistFilename=[[NSString alloc] initWithString:fileName];
mPlaylist[0].mPlaylistFilepath=[[NSString alloc] initWithString:filePath];
//[self checkAvailableCovers:0];
mPlaylist[0].cover_flag=-1;
added_pos=0;
mPlaylist_size=1;
mPlaylist[added_pos].mPlaylistCount=0;
rating=0;
DBHelper::getFileStatsDBmod(mPlaylist[added_pos].mPlaylistFilename,mPlaylist[added_pos].mPlaylistFilepath,&playcount,&rating);
mPlaylist[added_pos].mPlaylistRating=rating;
mPlaylist_pos=0;
[playlistTabView reloadData];
[self play_curEntry];
playLaunched=1;
}
if ((!forcenoplay)&&(sc_DefaultAction.selectedSegmentIndex==2)) {//Enqueue & play
mPlaylist_pos=added_pos;
[self play_curEntry];
playLaunched=1;
}
NSIndexPath *myindex=[[NSIndexPath alloc] initWithIndex:0];
if (mPlaylist_size) [self.playlistTabView selectRowAtIndexPath:[myindex indexPathByAddingIndex:mPlaylist_pos] animated:TRUE scrollPosition:UITableViewScrollPositionMiddle];
[myindex autorelease];
return playLaunched;
}
-(void) remove_from_playlist:(int)index {//remove entry
coverflow_needredraw=1;
if (mPlaylist_size) { //ensure playlist is not empty
[mPlaylist[index].mPlaylistFilename autorelease];
[mPlaylist[index].mPlaylistFilepath autorelease];
for (int i=index;i<mPlaylist_size-1;i++) {
mPlaylist[i]=mPlaylist[i+1];
}
mPlaylist_size--;
if ((index<mPlaylist_pos)||(mPlaylist_pos==mPlaylist_size)) mPlaylist_pos--;
[playlistTabView reloadData];
//playlistPos.text=[NSString stringWithFormat:@"%d on %d",mPlaylist_pos,mPlaylist_size];
mShouldUpdateInfos=1;
}
if (mPlaylist_size) {
NSIndexPath *myindex=[[NSIndexPath alloc] initWithIndex:0];
[self.playlistTabView selectRowAtIndexPath:[myindex indexPathByAddingIndex:mPlaylist_pos] animated:TRUE scrollPosition:UITableViewScrollPositionMiddle];
[myindex autorelease];
}
}
-(NSString*) getCurrentModuleFilepath {
if (mPlaylist_size==0) return nil;
return mPlaylist[mPlaylist_pos].mPlaylistFilepath;
}
-(BOOL) play_loadArchiveModule {
short int playcount=0;
int retcode;
NSString *fileName=mPlaylist[mPlaylist_pos].mPlaylistFilename;
NSString *filePath=mPlaylist[mPlaylist_pos].mPlaylistFilepath;
if (!filePath) return FALSE;
mOnlyCurrentEntry=0;
mOnlyCurrentSubEntry=0;
mSendStatTimer=0;
// if already playing, stop
if ([mplayer isPlaying]) {
[repeatingTimer invalidate];
repeatingTimer = nil; // ensures we never invalidate an already invalid Timer
[mplayer Stop];
}
// load module
if (retcode=[mplayer LoadModule:filePath defaultMODPLAYER:sc_defaultMODplayer.selectedSegmentIndex slowDevice:mSlowDevice archiveMode:1 archiveIndex:-1 singleSubMode:mOnlyCurrentSubEntry singleArcMode:mOnlyCurrentEntry]) {
//error while loading
NSLog(@"Issue in LoadModule(archive) %@",filePath);
if (retcode==-99) mLoadIssueMessage=0;
else mLoadIssueMessage=1;
return FALSE;
}
//fix issue with modplug settings reset after load
[self settingsChanged:nil];
pvSubSongSel.hidden=true;
pvSubSongLabel.hidden=true;
pvSubSongValidate.hidden=true;
[pvSubSongSel reloadAllComponents];
if ( ([mplayer isArchive]&&([mplayer getArcEntriesCnt]>1)&&(mOnlyCurrentEntry==0))|| ([mplayer isMultiSongs]&&(mOnlyCurrentSubEntry==0))) btnShowSubSong.hidden=false;
else btnShowSubSong.hidden=true;
pvArcSel.hidden=true,
pvArcLabel.hidden=true;
pvArcValidate.hidden=true;
[pvArcSel reloadAllComponents];
if ([mplayer isArchive]&&([mplayer getArcEntriesCnt]>1)&&(mOnlyCurrentEntry==0)) btnShowArcList.hidden=false;
else btnShowArcList.hidden=true;
alertCannotPlay_displayed=0;
//Visiulization stuff
startChan=0;
movePx=movePy=0;
sliderProgressModuleEdit=0;
sliderProgressModuleChanged=0;
//Update song info if required
labelModuleName.hidden=NO;
if (sc_titleFilename.selectedSegmentIndex) labelModuleName.text=[NSString stringWithString:fileName];
else labelModuleName.text=[NSString stringWithString:[mplayer getModName]];
lblCurrentSongCFlow.text=labelModuleName.text;
labelModuleName.textColor = [UIColor colorWithRed:0.95 green:0.95 blue:0.99 alpha:1.0];
labelModuleName.glowColor = [UIColor colorWithRed:0.40 green:0.40 blue:0.99 alpha:1.0];
labelModuleName.glowOffset = CGSizeMake(0.0, 0.0);
labelModuleName.glowAmount = 15.0;
[labelModuleName setNeedsDisplay];
self.navigationItem.titleView=labelModuleName;
labelModuleSize.text=[NSString stringWithFormat:NSLocalizedString(@"Size: %dKB",@""), mplayer.mp_datasize>>10];
if ([mplayer getSongLength]>0) {
labelModuleLength.text=[NSString stringWithFormat:@"%.2d:%.2d", ([mplayer getSongLength]/1000)/60,([mplayer getSongLength]/1000)%60];
sliderProgressModule.enabled=YES;
} else {
labelModuleLength.text=@"--:--";
sliderProgressModule.enabled=FALSE;
}
//Update rating info for playlist view
mRating=0;
DBHelper::getFileStatsDBmod(fileName,filePath,&playcount,&mRating);
mPlaylist[mPlaylist_pos].mPlaylistRating=mRating;
if (!mRestart) { //if not resuming, update playcount
playcount++;
DBHelper::updateFileStatsDBmod(fileName,filePath,playcount,mRating,[mplayer getSongLength],mplayer.numChannels,(mOnlyCurrentEntry==0?([mplayer isArchive]?-[mplayer getArcEntriesCnt]:mplayer.mod_subsongs):-1));
//UPDATE Google Application
if (sc_StatsUpload.selectedSegmentIndex) mSendStatTimer=15;//Wait 15 updateInfos call => 15*0.33 => 15seconds
}
[self showRating:mRating];
//Is OGLView visible ?
[self checkGLViewCanDisplay];
//update playback buttons
self.pauseBarSub.hidden=YES;
self.playBarSub.hidden=YES;
self.pauseBar.hidden=YES;
self.playBar.hidden=YES;
if ( ([mplayer isArchive]&&([mplayer getArcEntriesCnt]>1)&&(mOnlyCurrentEntry==0))|| ([mplayer isMultiSongs]&&(mOnlyCurrentSubEntry==0))) self.pauseBarSub.hidden=NO;
else self.pauseBar.hidden=NO;
[self updateBarPos];
[mplayer PlaySeek:mPlayingPosRestart subsong:0];
sliderProgressModule.value=0;
mIsPlaying=YES;
mPaused=0;
if (coverflow.hidden==NO) {
btnPlayCFlow.hidden=YES;
btnPauseCFlow.hidden=NO;
}
// [self openPopup:fileName];
// if (sc_SpokenTitle.selectedSegmentIndex==1) [fliteTTS speakText:[mplayer getModName]];
//set volume (if applicable)
[mplayer setModPlugMasterVol:mastVolSld.value];
labelTime.text=@"00:00";
if (mplayer.numChannels) {
if (mplayer.numChannels==1) labelNumChannels.text=[NSString stringWithFormat:@"1 channel"];
else labelNumChannels.text=[NSString stringWithFormat:@"%d channels",mplayer.numChannels];
} else labelNumChannels.text=[NSString stringWithFormat:@""];
labelModuleType.text=[NSString stringWithFormat:@"Format: %@",[mplayer getModType]];
labelLibName.text=[NSString stringWithFormat:@"Player: %@",[mplayer getPlayerName]];
textMessage.text=[NSString stringWithFormat:@"\n%@",[mplayer getModMessage]];
[textMessage scrollRangeToVisible:NSMakeRange(0, 1)];
//Activate timer for play infos
repeatingTimer = [NSTimer scheduledTimerWithTimeInterval: 0.33 target:self selector:@selector(updateInfos:) userInfo:nil repeats: YES]; //3 times/second
if (sc_cflow.selectedSegmentIndex) {
if (coverflow.currentIndex!=mPlaylist_pos) {
coverflow_pos=mPlaylist_pos;
[coverflow setCurrentIndex:mPlaylist_pos];
//[coverflow bringCoverAtIndexToFront:mPlaylist_pos animated:YES];
}
}
return TRUE;
}
- (void)titleTap:(UITapGestureRecognizer *)sender {
// NSLog(@"%@",labelModuleName.text);
[self openPopup:labelModuleName.text];
}
-(BOOL)play_module:(NSString *)filePath fname:(NSString *)fileName {
short int playcount=0;
int retcode;
NSString *filePathTmp;
mSendStatTimer=0;
shouldRestart=0;
if (!filePath) return FALSE;
if (!fileName) return FALSE;
// if already playing, stop
if ([mplayer isPlaying]) {
[repeatingTimer invalidate];
repeatingTimer = nil; // ensures we never invalidate an already invalid Timer
[mplayer Stop];
}
//Update position
/* if (locManager_isOn==1) {
if (locationLastUpdate) {
int i=[locationLastUpdate timeIntervalSinceNow];
if (i<-LOCATION_UPDATE_TIMING) {
locManager_isOn=2;
[self.locManager startUpdatingLocation];
[locationLastUpdate release];
locationLastUpdate=[[NSDate alloc] init];
}
}
}*/
// load module
const char *tmp_str=[filePath UTF8String];
char tmp_str_copy[1024];
int found_arc=0;
int arc_index=0;
int found_sub=0;
int sub_index=0;
int i=0;
mOnlyCurrentEntry=0;
mOnlyCurrentSubEntry=0;
while (tmp_str[i]) {
if (found_arc) {
arc_index=arc_index*10+tmp_str[i]-'0';
mOnlyCurrentEntry=1;
}
if (found_sub) {
sub_index=sub_index*10+tmp_str[i]-'0';
mOnlyCurrentSubEntry=1;
}
if (tmp_str[i]=='@') {
found_arc=1;
memcpy(tmp_str_copy,tmp_str,i);
tmp_str_copy[i]=0;
filePathTmp=[NSString stringWithFormat:@"%s",tmp_str_copy];
}
if (tmp_str[i]=='?') {
found_sub=1;
memcpy(tmp_str_copy,tmp_str,i);
tmp_str_copy[i]=0;
filePathTmp=[NSString stringWithFormat:@"%s",tmp_str_copy];
}
i++;
}
if ((found_arc==0)&&(found_sub==0)) filePathTmp=[NSString stringWithString:filePath];
if (mRestart) {
} else {
mRestart_arc=arc_index;
mRestart_sub=sub_index;
}
if (retcode=[mplayer LoadModule:filePathTmp defaultMODPLAYER:sc_defaultMODplayer.selectedSegmentIndex slowDevice:mSlowDevice archiveMode:0 archiveIndex:mRestart_arc singleSubMode:mOnlyCurrentSubEntry singleArcMode:mOnlyCurrentEntry]) {
//error while loading
NSLog(@"Issue in LoadModule %@",filePathTmp);
mRestart=0;
mRestart_sub=0;
mRestart_arc=0;
if (retcode==-99) mLoadIssueMessage=0;
else mLoadIssueMessage=1;
return FALSE;
}
//fix issue with modplug settings reset after load
[self settingsChanged:nil];
NSString *pathFolderImgPNG,*pathFileImgPNG,*pathFolderImgJPG,*pathFileImgJPG,*pathFolderImgGIF,*pathFileImgGIF;
pathFolderImgPNG=[NSHomeDirectory() stringByAppendingFormat:@"/%@/folder.png",[filePathTmp stringByDeletingLastPathComponent]];
pathFolderImgJPG=[NSHomeDirectory() stringByAppendingFormat:@"/%@/folder.jpg",[filePathTmp stringByDeletingLastPathComponent]];
pathFolderImgGIF=[NSHomeDirectory() stringByAppendingFormat:@"/%@/folder.gif",[filePathTmp stringByDeletingLastPathComponent]];
pathFileImgPNG=[NSHomeDirectory() stringByAppendingFormat:@"/%@.png",[filePathTmp stringByDeletingPathExtension]];
pathFileImgJPG=[NSHomeDirectory() stringByAppendingFormat:@"/%@.jpg",[filePathTmp stringByDeletingPathExtension]];
pathFileImgGIF=[NSHomeDirectory() stringByAppendingFormat:@"/%@.gif",[filePathTmp stringByDeletingPathExtension]];
UIImage *cover_img=nil;
// cover_img=[UIImage imageWithData:[NSData dataWithContentsOfFile:pathFolderImgPNG]];
if (gifAnimation) [gifAnimation removeFromSuperview];
gifAnimation=nil;
cover_img=[UIImage imageWithContentsOfFile:pathFileImgJPG];
if (cover_img==nil) cover_img=[UIImage imageWithContentsOfFile:pathFileImgPNG];
if (cover_img==nil) {
cover_img=[UIImage imageWithContentsOfFile:pathFileImgGIF];
if (cover_img) {
NSURL* firstUrl = [NSURL fileURLWithPath:pathFileImgGIF];
gifAnimation = [AnimatedGif getAnimationForGifAtUrl: firstUrl];
gifAnimation.frame=CGRectMake(cover_view.frame.origin.x, cover_view.frame.origin.y, cover_view.frame.size.width,cover_view.frame.size.height);
[cover_view addSubview:gifAnimation];
}
}
if (cover_img==nil) cover_img=[UIImage imageWithContentsOfFile:pathFolderImgJPG];
if (cover_img==nil) cover_img=[UIImage imageWithContentsOfFile:pathFolderImgPNG];
if (cover_img==nil) {
cover_img=[UIImage imageWithContentsOfFile:pathFolderImgGIF];
if (cover_img) {
NSURL* firstUrl = [NSURL fileURLWithPath:pathFileImgGIF];
gifAnimation= [AnimatedGif getAnimationForGifAtUrl: firstUrl];
gifAnimation.frame=CGRectMake(0, 0, mDevice_ww, mDevice_hh-234+82);
[gifAnimation layoutSubviews];
[cover_view addSubview:gifAnimation];
}
}
if (cover_img) {
cover_view.image=cover_img;
cover_view.hidden=FALSE;
} else cover_view.hidden=TRUE;
//[self checkAvailableCovers:mPlaylist_pos];
mPlaylist[mPlaylist_pos].cover_flag=-1;
pvSubSongSel.hidden=true;
pvSubSongLabel.hidden=true;
pvSubSongValidate.hidden=true;
[pvSubSongSel reloadAllComponents];
if ( ([mplayer isArchive]&&([mplayer getArcEntriesCnt]>1)&&(mOnlyCurrentEntry==0))|| ([mplayer isMultiSongs]&&(mOnlyCurrentSubEntry==0))) btnShowSubSong.hidden=false;
else btnShowSubSong.hidden=true;
pvArcSel.hidden=true,
pvArcLabel.hidden=true;
pvArcValidate.hidden=true;
[pvArcSel reloadAllComponents];
if ([mplayer isArchive]&&([mplayer getArcEntriesCnt]>1)&&(mOnlyCurrentEntry==0)) btnShowArcList.hidden=false;
else btnShowArcList.hidden=true;
alertCannotPlay_displayed=0;
//Visiulization stuff
startChan=0;
movePx=movePy=0;
sliderProgressModuleEdit=0;
sliderProgressModuleChanged=0;
//Update song info if required
labelModuleName.hidden=NO;
if (sc_titleFilename.selectedSegmentIndex) labelModuleName.text=[NSString stringWithString:fileName];
else labelModuleName.text=[NSString stringWithString:[mplayer getModName]];
lblCurrentSongCFlow.text=labelModuleName.text;
labelModuleName.textColor = [UIColor colorWithRed:0.95 green:0.95 blue:0.99 alpha:1.0];
labelModuleName.glowColor = [UIColor colorWithRed:0.40 green:0.40 blue:0.99 alpha:1.0];
labelModuleName.glowOffset = CGSizeMake(0.0, 0.0);
labelModuleName.glowAmount = 15.0;
[labelModuleName setNeedsDisplay];
self.navigationItem.titleView=labelModuleName;
labelModuleSize.text=[NSString stringWithFormat:NSLocalizedString(@"Size: %dKB",@""), mplayer.mp_datasize>>10];
if ([mplayer getSongLength]>0) {
labelModuleLength.text=[NSString stringWithFormat:@"%.2d:%.2d", ([mplayer getSongLength]/1000)/60,([mplayer getSongLength]/1000)%60];
sliderProgressModule.enabled=YES;
} else {
labelModuleLength.text=@"--:--";
sliderProgressModule.enabled=FALSE;
}
//Update rating info for playlist view
mRating=0;
DBHelper::getFileStatsDBmod(fileName,filePath,&playcount,&mRating);
mPlaylist[mPlaylist_pos].mPlaylistRating=mRating;
if (!mRestart) { //if not resuming, update playcount
playcount++;
DBHelper::updateFileStatsDBmod(fileName,filePath,playcount,mRating,[mplayer getSongLength],mplayer.numChannels,(mOnlyCurrentEntry==0?([mplayer isArchive]?-[mplayer getArcEntriesCnt]:mplayer.mod_subsongs):-1));
//UPDATE Google Application
if (sc_StatsUpload.selectedSegmentIndex) mSendStatTimer=15;//Wait 15 updateInfos call => 15*0.33 => 15seconds
}
[self showRating:mRating];
//Is OGLView visible ?
[self checkGLViewCanDisplay];
//Restart management
if (mRestart) {
mRestart=0;
self.pauseBarSub.hidden=YES;
self.playBarSub.hidden=YES;
self.pauseBar.hidden=YES;
self.playBar.hidden=YES;
if ( ([mplayer isArchive]&&([mplayer getArcEntriesCnt]>1)&&(mOnlyCurrentEntry==0))|| ([mplayer isMultiSongs]&&(mOnlyCurrentSubEntry==0))) self.playBarSub.hidden=NO;
else self.playBar.hidden=NO;
[self updateBarPos];
// NSLog(@"yo %d",mRestart_sub);
[mplayer PlaySeek:mPlayingPosRestart subsong:mRestart_sub];
// NSLog(@"yo1");
if (mPlayingPosRestart) {
mPlayingPosRestart=0;
} else sliderProgressModule.value=0;
// NSLog(@"yo2");
[mplayer Pause:YES];
// NSLog(@"yo3");
mIsPlaying=YES;
mPaused=1;
} else {
self.pauseBarSub.hidden=YES;
self.playBarSub.hidden=YES;
self.pauseBar.hidden=YES;
self.playBar.hidden=YES;
if ( ([mplayer isArchive]&&([mplayer getArcEntriesCnt]>1)&&(mOnlyCurrentEntry==0))|| ([mplayer isMultiSongs]&&(mOnlyCurrentSubEntry==0))) self.pauseBarSub.hidden=NO;
else self.pauseBar.hidden=NO;
[self updateBarPos];
mRestart=0;
[mplayer PlaySeek:mPlayingPosRestart subsong:mRestart_sub];
if (mPlayingPosRestart) {
mPlayingPosRestart=0;
} else sliderProgressModule.value=0;
mIsPlaying=YES;
mPaused=0;
// [self openPopup:fileName];
// if (sc_SpokenTitle.selectedSegmentIndex==1) [fliteTTS speakText:[mplayer getModName]];
}
mRestart_sub=0;
mRestart_arc=0;
//set volume (if applicable)
[mplayer setModPlugMasterVol:mastVolSld.value];
if (coverflow.hidden==NO) {
btnPlayCFlow.hidden=YES;
btnPauseCFlow.hidden=NO;
}
if (sc_cflow.selectedSegmentIndex) {
if (coverflow.currentIndex!=mPlaylist_pos) {
coverflow_pos=mPlaylist_pos;
[coverflow setCurrentIndex:mPlaylist_pos];
//[coverflow bringCoverAtIndexToFront:mPlaylist_pos animated:YES];
}
}
labelTime.text=@"00:00";
if (mplayer.numChannels) {
if (mplayer.numChannels==1) labelNumChannels.text=[NSString stringWithFormat:@"1 channel"];
else labelNumChannels.text=[NSString stringWithFormat:@"%d channels",mplayer.numChannels];
} else labelNumChannels.text=[NSString stringWithFormat:@""];
labelModuleType.text=[NSString stringWithFormat:@"Format: %@",[mplayer getModType]];
labelLibName.text=[NSString stringWithFormat:@"Player: %@",[mplayer getPlayerName]];
textMessage.text=[NSString stringWithFormat:@"\n%@",[mplayer getModMessage]];
[textMessage scrollRangeToVisible:NSMakeRange(0, 1)];
//Activate timer for play infos
repeatingTimer = [NSTimer scheduledTimerWithTimeInterval: 0.33 target:self selector:@selector(updateInfos:) userInfo:nil repeats: YES]; //3 times/second
return TRUE;
}
#pragma mark -
#pragma mark Managing the detail item
/*
When setting the detail item, update the view and dismiss the popover controller if it's showing.
*/
/*
- (void)setDetailItem:(id)newDetailItem {
if (detailItem != newDetailItem) {
[detailItem release];
detailItem = [newDetailItem retain];
// Update the view.
[self configureView];
}
}
- (void)configureView {
// Update the user interface for the detail item.
detailDescriptionLabel.text = [detailItem description];
}
*/
#pragma mark -
#pragma mark Rotation support
//- (void)willAnimateSecondHalfOfRotationFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation duration:(NSTimeInterval)duration {
//- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration {
/*- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
if ((fromInterfaceOrientation==UIInterfaceOrientationPortrait)||(fromInterfaceOrientation==UIInterfaceOrientationPortraitUpsideDown)) {
} else {
}
}*/
// Ensure that the view controller supports rotation and that the split view can therefore show in both portrait and landscape.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
orientationHV=interfaceOrientation;
if ((interfaceOrientation==UIInterfaceOrientationPortrait)||(interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown)) {
waitingView.transform=CGAffineTransformMakeRotation(interfaceOrientation==UIInterfaceOrientationPortrait?0:M_PI);
if (coverflow.hidden==FALSE) {
[UIView beginAnimations:@"cflow_out" context:nil];
[UIView setAnimationDelay:0.0];
[UIView setAnimationDuration:0.4];
[UIView setAnimationDelegate:self];
coverflow.alpha=0.0;
lblMainCoverflow.alpha=0;
lblSecCoverflow.alpha=0;
lblCurrentSongCFlow.alpha=0;
lblTimeFCflow.alpha=0;
btnPlayCFlow.alpha=0;
btnPauseCFlow.alpha=0;
btnBackCFlow.alpha=0;
[UIView commitAnimations];
[[self navigationController] setNavigationBarHidden:NO animated:NO];
}
if (oglViewFullscreen) {
//self.navigationController.navigationBar.hidden = YES;
mainView.frame = CGRectMake(0, 0, mDevice_ww, mDevice_hh-20-42);
m_oglView.frame = CGRectMake(0.0, 0.0, mDevice_ww, mDevice_hh-20-42);
} else {
//self.navigationController.navigationBar.hidden = NO;
mainView.frame = CGRectMake(0, 0, mDevice_ww, mDevice_hh-20-42);
m_oglView.frame = CGRectMake(0, 80, mDevice_ww, mDevice_hh-234+4);
cover_view.frame = CGRectMake(0, 0, mDevice_ww, mDevice_hh-234+82);
if (gifAnimation) gifAnimation.frame = CGRectMake(0, 0, mDevice_ww, mDevice_hh-234+82);
oglButton.frame = CGRectMake(0, 82, mDevice_ww, mDevice_hh-234);
volWin.frame= CGRectMake(0, mDevice_hh-64-42, mDevice_ww, 44);
volumeView.frame = volWin.bounds;
// volumeView.center = CGPointMake((mDevice_ww)/2,32);
// [volumeView sizeToFit];
if (infoIsFullscreen) infoView.frame = CGRectMake(0, 0, mDevice_ww, mDevice_hh-20-42);
else infoView.frame = CGRectMake(0, 82, mDevice_ww, mDevice_hh-234);
if (plIsFullscreen) playlistView.frame = CGRectMake(0, 0, mDevice_ww, mDevice_hh-20-42);
else playlistView.frame = CGRectMake(0, 82, mDevice_ww, mDevice_hh-234);
commandViewU.frame = CGRectMake(2, 48, mDevice_ww-4, 32);
buttonLoopTitleSel.frame = CGRectMake(10,0,32,32);
buttonLoopList.frame = CGRectMake(10,0,32,32);
buttonLoopListSel.frame = CGRectMake(10,0,32,32);
buttonShuffle.frame = CGRectMake(50,0,32,32);
buttonShuffleSel.frame = CGRectMake(50,0,32,32);
btnLoopInf.frame = CGRectMake(88,-12,35,57);
btnShowSubSong.frame = CGRectMake(mDevice_ww-36,0,32,32);
btnShowArcList.frame = CGRectMake(mDevice_ww-36-36,0,32,32);
infoButton.frame = CGRectMake(mDevice_ww-40,0,40,40);
mainRating1.frame = CGRectMake(130,3,24,24);
mainRating2.frame = CGRectMake(130+24,3,24,24);
mainRating3.frame = CGRectMake(130+24*2,3,24,24);
mainRating4.frame = CGRectMake(130+24*3,3,24,24);
mainRating5.frame = CGRectMake(130+24*4,3,24,24);
mainRating1off.frame = CGRectMake(130,3,24,24);
mainRating2off.frame = CGRectMake(130+24,3,24,24);
mainRating3off.frame = CGRectMake(130+24*2,3,24,24);
mainRating4off.frame = CGRectMake(130+24*3,3,24,24);
mainRating5off.frame = CGRectMake(130+24*4,3,24,24);
playlistPos.frame = CGRectMake(mDevice_ww/2-90,0,180,20);
labelModuleLength.frame=CGRectMake(mDevice_ww-47,24,45,20);
labelTime.frame=CGRectMake(2,24,45,20);
sliderProgressModule.frame = CGRectMake(48,23,mDevice_ww-48*2,23);
}
} else{
waitingView.transform=CGAffineTransformMakeRotation(interfaceOrientation==UIInterfaceOrientationLandscapeLeft?-M_PI_2:M_PI_2);
if ((mPlaylist_size>0)&&(sc_cflow.selectedSegmentIndex)) {
//[coverflow setNumberOfCovers:mPlaylist_size];
//coverflow.currentIndex=mPlaylist_pos;
if (coverflow_needredraw||(coverflow_plsize!=mPlaylist_size)) {
coverflow_plsize=mPlaylist_size;
coverflow_pos=mPlaylist_pos;
coverflow_needredraw=0;
[coverflow setNumberOfCovers:mPlaylist_size pos:coverflow_pos];
}
if (coverflow.currentIndex!=mPlaylist_pos) {
coverflow_pos=mPlaylist_pos;
//coverflow.currentIndex=mPlaylist_pos;
[coverflow setCurrentIndex:mPlaylist_pos];
}
coverflow.alpha=0;
lblMainCoverflow.alpha=0;
lblSecCoverflow.alpha=0;
lblCurrentSongCFlow.alpha=0;
lblTimeFCflow.alpha=0;
btnPlayCFlow.alpha=0;
btnPauseCFlow.alpha=0;
btnBackCFlow.alpha=0;
coverflow.hidden=FALSE;
lblMainCoverflow.hidden=FALSE;
lblSecCoverflow.hidden=FALSE;
lblCurrentSongCFlow.hidden=FALSE;
lblTimeFCflow.hidden=FALSE;
btnBackCFlow.hidden=FALSE;
if (mPaused||(![mplayer isPlaying])) btnPlayCFlow.hidden=FALSE;
else btnPauseCFlow.hidden=FALSE;
[[self navigationController] setNavigationBarHidden:YES animated:NO];
[UIView beginAnimations:@"cflow_in" context:nil];
[UIView setAnimationDelay:0.0];
[UIView setAnimationDuration:0.40];
// [UIView setAnimationDelegate:self];
coverflow.alpha=1.0;
lblMainCoverflow.alpha=1.0;
lblSecCoverflow.alpha=1.0;
lblCurrentSongCFlow.alpha=1.0;
lblTimeFCflow.alpha=1.0;
btnPlayCFlow.alpha=1.0;
btnPauseCFlow.alpha=1.0;
btnBackCFlow.alpha=1.0;
[UIView commitAnimations];
if (mDeviceType==1) {
lblMainCoverflow.frame=CGRectMake(0,mDevice_ww-40-64,mDevice_hh,40);
lblSecCoverflow.frame=CGRectMake(40,mDevice_ww-40-24,mDevice_hh-80,24);
lblCurrentSongCFlow.frame=CGRectMake(0,0,mDevice_hh*2/3,24);
lblTimeFCflow.frame=CGRectMake(mDevice_hh*2/3,0,mDevice_hh/3,24);
btnPlayCFlow.frame=CGRectMake(8,mDevice_ww-40-32,32,32);
btnPauseCFlow.frame=CGRectMake(8,mDevice_ww-40-32,32,32);
btnBackCFlow.frame=CGRectMake(8,32,32,32);
} else {
lblMainCoverflow.frame=CGRectMake(0,mDevice_ww-40-32,mDevice_hh,20);
lblSecCoverflow.frame=CGRectMake(40,mDevice_ww-40-12,mDevice_hh-80,12);
lblCurrentSongCFlow.frame=CGRectMake(0,0,mDevice_hh*2/3,12);
lblTimeFCflow.frame=CGRectMake(mDevice_hh*2/3,0,mDevice_hh/3,12);
btnPlayCFlow.frame=CGRectMake(4,mDevice_ww-32-32,32,32);
btnPauseCFlow.frame=CGRectMake(4,mDevice_ww-32-32,32,32);
btnBackCFlow.frame=CGRectMake(4,16,32,32);
}
lblMainCoverflow.hidden=FALSE;
lblSecCoverflow.hidden=FALSE;
lblCurrentSongCFlow.hidden=FALSE;
lblTimeFCflow.hidden=FALSE;
btnBackCFlow.hidden=FALSE;
if (mPaused||(![mplayer isPlaying])) {
btnPlayCFlow.hidden=FALSE;
btnPauseCFlow.hidden=TRUE;
}
else {
btnPauseCFlow.hidden=FALSE;
btnPlayCFlow.hidden=TRUE;
}
} else {
if (oglViewFullscreen) {
//self.navigationController.navigationBar.hidden = YES;
mainView.frame = CGRectMake(0.0, 0, mDevice_hh, mDevice_ww-20-30);
m_oglView.frame = CGRectMake(0.0, 0.0, mDevice_hh, mDevice_ww-20-30); //ipad
} else {
//self.navigationController.navigationBar.hidden = NO;
mainView.frame = CGRectMake(0.0, 0, mDevice_hh, mDevice_ww-20-30);
m_oglView.frame = CGRectMake(0.0, 82, mDevice_hh, mDevice_ww-104-30);
cover_view.frame = CGRectMake(0.0, 0, mDevice_hh, mDevice_ww-104-30+82);
if (gifAnimation) gifAnimation.frame = CGRectMake(0.0, 0, mDevice_hh, mDevice_ww-104-30+82);
oglButton.frame = CGRectMake(0.0, 82, mDevice_hh, mDevice_ww-104-30);
volWin.frame= CGRectMake(200, 41, mDevice_hh-375, 44);
volumeView.frame = volWin.bounds;
// volumeView.frame = CGRectMake(10, 0, mDevice_hh-375-10, 44);
// volumeView.center = CGPointMake((mDevice_hh-375)/2,32);
// [volumeView sizeToFit];
if (infoIsFullscreen) infoView.frame = CGRectMake(0.0, 0, mDevice_hh, mDevice_ww-20-30);
else infoView.frame = CGRectMake(0.0, 82, mDevice_hh, mDevice_ww-104-30);
if (plIsFullscreen) playlistView.frame = CGRectMake(0.0, 0, mDevice_hh, mDevice_ww-20-30);
else playlistView.frame = CGRectMake(0.0, 82, mDevice_hh, mDevice_ww-104-30);
commandViewU.frame = CGRectMake(mDevice_hh-72-40-31-20-4, 8, 40+72+31+20, 32+32);
buttonLoopTitleSel.frame = CGRectMake(2,0,40,32);
buttonLoopList.frame = CGRectMake(2,0,40,32);
buttonLoopListSel.frame = CGRectMake(2,0,40,32);
buttonShuffle.frame = CGRectMake(42,0,40,32);
buttonShuffleSel.frame = CGRectMake(42,0,40,32);
btnLoopInf.frame = CGRectMake(80,-12,35,57);
mainRating1.frame = CGRectMake(6,36,24,24);
mainRating2.frame = CGRectMake(6+24,36,24,24);
mainRating3.frame = CGRectMake(6+24*2,36,24,24);
mainRating4.frame = CGRectMake(6+24*3,36,24,24);
mainRating5.frame = CGRectMake(6+24*4,36,24,24);
mainRating1off.frame = CGRectMake(6,36,24,24);
mainRating2off.frame = CGRectMake(6+24,36,24,24);
mainRating3off.frame = CGRectMake(6+24*2,36,24,24);
mainRating4off.frame = CGRectMake(6+24*3,36,24,24);
mainRating5off.frame = CGRectMake(6+24*4,36,24,24);
btnShowSubSong.frame = CGRectMake(124+7,0,32,32);
btnShowArcList.frame = CGRectMake(124+7,32,32,32);
infoButton.frame = CGRectMake(mDevice_hh-200+6,14,18,19);
playlistPos.frame = CGRectMake((mDevice_hh-200)/2-90,0,180,20);
labelTime.frame=CGRectMake(2,17,45,20);
labelModuleLength.frame=CGRectMake(mDevice_hh-200-47,17,45,20);
sliderProgressModule.frame = CGRectMake(48,16,mDevice_hh-200-48*2,23);
}
}
}
[self updateBarPos];
int size_chan=12*6;
if (segcont_shownote.selectedSegmentIndex==2) size_chan=6*6;
visibleChan=(m_oglView.frame.size.width-NOTES_DISPLAY_LEFTMARGIN)/size_chan;
if (startChan>mplayer.numChannels-visibleChan) startChan=mplayer.numChannels-visibleChan;
if (startChan<0) startChan=0;
tim_midifx_note_range=88; //88notes on a Piano
tim_midifx_note_offset=0;
return YES;
}
-(void)updateBarPos {
if ((orientationHV==UIInterfaceOrientationPortrait)||(orientationHV==UIInterfaceOrientationPortraitUpsideDown)) {
playBar.frame = CGRectMake(0, mDevice_hh-(playBar.hidden?0:108+42), mDevice_ww, 44);
pauseBar.frame = CGRectMake(0, mDevice_hh-(pauseBar.hidden?0:108+42), mDevice_ww, 44);
playBarSub.frame = CGRectMake(0, mDevice_hh-(playBarSub.hidden?0:108+42), mDevice_ww, 44);
pauseBarSub.frame = CGRectMake(0, mDevice_hh-(pauseBarSub.hidden?0:108+42), mDevice_ww, 44);
} else {
playBar.frame = CGRectMake(0, 40, 200, 44); //mDevice_hh-(playBar.hidden?0:375)
pauseBar.frame = CGRectMake(0, 40, 200, 44);
playBarSub.frame = CGRectMake(0, 40, 200, 44);
pauseBarSub.frame = CGRectMake(0, 40, 200, 44);
}
}
#pragma mark -
#pragma mark View lifecycle
/**************************************************/
/**************************************************/
/**************************************************/
/* User Defined Variables */
GLfloat angle; /* Used To Rotate The Helix */
GLfloat vertices[4][3]; /* Holds Float Info For 4 Sets Of Vertices */
GLfloat vertColor[4][4]; /* Holds Float Info For 4 Sets Of Vertices */
GLfloat texcoords[4][2]; /* Holds Float Info For 4 Sets Of Texture coordinates. */
GLfloat normalData[3]; /* An Array To Store The Normal Data */
//GLuint BlurTexture,FxTexture; /* An Unsigned Int To Store The Texture Number */
/* Create Storage Space For Texture Data (128x128x4) */
/* Create An Empty Texture */
GLuint EmptyTexture(int ww,int hh)
{
GLuint txtnumber; /* Texture ID */
unsigned int *dataText; /* Stored Data */
dataText=(unsigned int*)malloc(ww*hh*4*sizeof(unsigned int));
glGenTextures(1, &txtnumber); /* Create 1 Texture */
glBindTexture(GL_TEXTURE_2D, txtnumber); /* Bind The Texture */
/* Build Texture Using Information In data */
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, ww, hh,
0, GL_RGBA, GL_UNSIGNED_BYTE, dataText);
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glBindTexture(GL_TEXTURE_2D, 0);
free(dataText);
/* Return The Texture ID */
return txtnumber;
}
/* Reduces A Normal Vector (3 Coordinates) */
/* To A Unit Normal Vector With A Length Of One. */
void ReduceToUnit(GLfloat vector[3])
{
/* Holds Unit Length */
GLfloat length;
/* Calculates The Length Of The Vector */
length=(GLfloat)sqrt((vector[0]*vector[0])+(vector[1]*vector[1])+(vector[2]*vector[2]));
/* Prevents Divide By 0 Error By Providing */
if (length==0.0f)
{
/* An Acceptable Value For Vectors To Close To 0. */
length=1.0f;
}
vector[0]/=length; /* Dividing Each Element By */
vector[1]/=length; /* The Length Results In A */
vector[2]/=length; /* Unit Normal Vector. */
}
/* Calculates Normal For A Quad Using 3 Points */
void calcNormal(GLfloat v[3][3], GLfloat out[3])
{
/* Vector 1 (x,y,z) & Vector 2 (x,y,z) */
GLfloat v1[3], v2[3];
/* Define X Coord */
static const int x=0;
/* Define Y Coord */
static const int y=1;
/* Define Z Coord */
static const int z=2;
/* Finds The Vector Between 2 Points By Subtracting */
/* The x,y,z Coordinates From One Point To Another. */
/* Calculate The Vector From Point 1 To Point 0 */
v1[x]=v[0][x]-v[1][x]; /* Vector 1.x=Vertex[0].x-Vertex[1].x */
v1[y]=v[0][y]-v[1][y]; /* Vector 1.y=Vertex[0].y-Vertex[1].y */
v1[z]=v[0][z]-v[1][z]; /* Vector 1.z=Vertex[0].y-Vertex[1].z */
/* Calculate The Vector From Point 2 To Point 1 */
v2[x]=v[1][x]-v[2][x]; /* Vector 2.x=Vertex[0].x-Vertex[1].x */
v2[y]=v[1][y]-v[2][y]; /* Vector 2.y=Vertex[0].y-Vertex[1].y */
v2[z]=v[1][z]-v[2][z]; /* Vector 2.z=Vertex[0].z-Vertex[1].z */
/* Compute The Cross Product To Give Us A Surface Normal */
out[x]=v1[y]*v2[z]-v1[z]*v2[y]; /* Cross Product For Y - Z */
out[y]=v1[z]*v2[x]-v1[x]*v2[z]; /* Cross Product For X - Z */
out[z]=v1[x]*v2[y]-v1[y]*v2[x]; /* Cross Product For X - Y */
ReduceToUnit(out); /* Normalize The Vectors */
}
void ProcessSpectrum(int ww,int hh,short int *spectrumDataL,short int *spectrumDataR,int numval)
{
GLfloat x,x1,x2;
GLfloat y,y1,y2;
GLfloat z;
GLfloat phi; /* Angle */
GLfloat v; /* Angles */
GLfloat r,cr,cg,cb,rf,cmax;
//////////////////////////////
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
const float aspectRatio = (float)ww/(float)hh;
const float _hw = 0.1f;
const float _hh = _hw/aspectRatio;
glFrustumf(-_hw, _hw, -_hh, _hh, 0.4f, 100.0f);
glPushMatrix(); /* Push The Modelview Matrix */
glTranslatef(0.0, 0.0, -50.0); /* Translate 50 Units Into The Screen */
//glRotatef(30.0f*sin(angle*0.11f*3.1459f/180.0f), 1, 0 ,0);
//glRotatef(20.0f*sin(angle*0.17f*3.1459f/180.0f), 0, 1 ,0);
glRotatef(angle/20.0f, 0, 0, 1);
/* Begin Drawing Quads, setup vertex array pointer */
glVertexPointer(3, GL_FLOAT, 0, vertices);
glColorPointer(4, GL_FLOAT, 0, vertColor);
/* Enable Vertex Pointer */
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
/* 360 Degrees In Steps Of 20 */
for (int i=0; i<numval*2; i++)
{
if (i<numval) {
r=(float)spectrumDataL[i]/512.0f;
cr=(float)i/(float)numval*2+0.2f;
cg=(float)i/(float)numval;
cb=(float)i/(float)numval/3;
}
else {
r=(float)spectrumDataR[(2*numval-1-i)]/512.0f;
cg=(float)(i-numval)/(float)numval*2+0.2f;
cr=(float)(i-numval)/(float)numval;
cb=(float)(i-numval)/(float)numval/3;
}
cr=cr*r/4.0f;
cg=cg*r/4.0f;
cb=cb*r/4.0f;
cmax=r/4.0f;
if (cr<0) cr=0; if (cr>1.0f) cr=1.0f;
if (cg<0) cg=0; if (cg>1.0f) cg=1.0f;
if (cb<0) cb=0; if (cb>1.0f) cb=1.0f;
vertColor[0][3]=vertColor[1][3]=vertColor[2][3]=1.0f;
phi=(float)i*360.0f/(float)numval/2;
/* Calculate Angle Of First Point (0) */
v=((phi)/180.0f*3.142f);
rf=1.0f+0.4*sin(angle*0.001f)*cos(v*(8+8*sin(angle*0.0008f))+angle*0.0010f);
/* Calculate x Position (1st Point) */
x1=(GLfloat)(cos(v)*(r+rf));
y1=(GLfloat)(sin(v)*(r+rf));
x2=(GLfloat)(cos(v)*(rf));
y2=(GLfloat)(sin(v)*(rf));
z=0.0f;
x=x1+(GLfloat)(sin(v)*0.8f);
y=y1-(GLfloat)(cos(v)*0.8f);
vertColor[0][0]=cr;vertColor[0][1]=cg;vertColor[0][2]=cb;
vertices[0][0]=x; /* Set x Value Of First Vertex */
vertices[0][1]=y; /* Set y Value Of First Vertex */
vertices[0][2]=z-1.0f; /* Set z Value Of First Vertex */
x=x2;
y=y2;
vertColor[1][0]=vertColor[1][1]=vertColor[1][2]=cmax;
vertices[1][0]=x; /* Set x Value Of Second Vertex */
vertices[1][1]=y; /* Set y Value Of Second Vertex */
vertices[1][2]=z; /* Set z Value Of Second Vertex */
x=x1-(GLfloat)(sin(v)*0.8f);
y=y1+(GLfloat)(cos(v)*0.8f);
vertColor[2][0]=cr;vertColor[2][1]=cg;vertColor[2][2]=cb;
vertices[2][0]=x; /* Set x Value Of First Vertex */
vertices[2][1]=y; /* Set y Value Of First Vertex */
vertices[2][2]=z-1.0f; /* Set z Value Of First Vertex */
calcNormal(vertices, normalData); /* Calculate The Quad Normal */
/* Set The Normal */
glNormal3f(normalData[0], normalData[1], normalData[2]);
/* Render The Quad */
glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
//same, but smaller
x1=(GLfloat)(cos(v)*(r*0.9f+rf+0.1f));
y1=(GLfloat)(sin(v)*(r*0.9f+rf+0.1f));
x2=(GLfloat)(cos(v)*(rf+0.1f));
y2=(GLfloat)(sin(v)*(rf+0.1f));
z=0.0f;
x=x1+(GLfloat)(sin(v)*0.6f);
y=y1-(GLfloat)(cos(v)*0.6f);
vertColor[0][0]=vertColor[0][1]=vertColor[0][2]=cmax;
vertices[0][0]=x; /* Set x Value Of First Vertex */
vertices[0][1]=y; /* Set y Value Of First Vertex */
vertices[0][2]=z-0.9f; /* Set z Value Of First Vertex */
x=x2;
y=y2;
vertColor[1][0]=cr;vertColor[1][1]=cg;vertColor[1][2]=cb;
vertices[1][0]=x; /* Set x Value Of Second Vertex */
vertices[1][1]=y; /* Set y Value Of Second Vertex */
vertices[1][2]=z; /* Set z Value Of Second Vertex */
x=x1-(GLfloat)(sin(v)*0.2f);
y=y1+(GLfloat)(cos(v)*0.2f);
vertColor[2][0]=vertColor[2][1]=vertColor[2][2]=cmax;
vertices[2][0]=x; /* Set x Value Of First Vertex */
vertices[2][1]=y; /* Set y Value Of First Vertex */
vertices[2][2]=z-0.9f; /* Set z Value Of First Vertex */
calcNormal(vertices, normalData); /* Calculate The Quad Normal */
/* Set The Normal */
glNormal3f(normalData[0], normalData[1], normalData[2]);
/* Render The Quad */
glDrawArrays(GL_TRIANGLE_STRIP, 0, 3);
}
/* Disable Vertex Pointer */
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
/* Pop The Matrix */
glPopMatrix();
}
/* Set Up An Ortho View */
void ViewOrtho(GLfloat window_width, GLfloat window_height)
{
glMatrixMode(GL_PROJECTION); /* Select Projection */
glPushMatrix(); /* Push The Matrix */
glLoadIdentity(); /* Reset The Matrix */
/* Select Ortho Mode (window_width x window_height) */
glOrthof(0, window_width, window_height, 0, -1, 1);
glMatrixMode(GL_MODELVIEW); /* Select Modelview Matrix */
glPushMatrix(); /* Push The Matrix */
glLoadIdentity(); /* Reset The Matrix */
}
/* Set Up A Perspective View */
void ViewPerspective()
{
glMatrixMode(GL_PROJECTION); /* Select Projection */
glPopMatrix(); /* Pop The Matrix */
glMatrixMode(GL_MODELVIEW); /* Select Modelview */
glPopMatrix(); /* Pop The Matrix */
}
void infoMenuShowImages(int window_width,int window_height,int alpha_byte ) {
glEnable(GL_TEXTURE_2D); /* Enable 2D Texture Mapping */
glDisable(GL_DEPTH_TEST); /* Disable Depth Testing */
glBlendFunc(GL_SRC_ALPHA, GL_ONE); /* Set Blending Mode */
glEnable(GL_BLEND); /* Enable Blending */
/* Bind To The Blur Texture */
/* Switch To An Ortho View */
ViewOrtho(window_width, window_height);
/* Begin Drawing Quads, setup vertex and texcoord array pointers */
glVertexPointer(3, GL_FLOAT, 0, vertices);
glTexCoordPointer(2, GL_FLOAT, 0, texcoords);
/* Enable Vertex Pointer */
glEnableClientState(GL_VERTEX_ARRAY);
/* Enable Texture Coordinations Pointer */
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glColor4f(1.0f, 1.0f, 1.0f, alpha_byte*1.0f/255.0f);
texcoords[0][0]=0.0f; texcoords[0][1]=0.0f;
texcoords[1][0]=0.0f; texcoords[1][1]=1.0f;
texcoords[2][0]=1.0f; texcoords[2][1]=0.0f;
texcoords[3][0]=1.0f; texcoords[3][1]=1.0f;
int marg=4;
for (int i=0;i<4;i++)
for (int j=0;j<4;j++) {
if (txtMenuHandle[i*4+j]) {
glBindTexture(GL_TEXTURE_2D, txtMenuHandle[i*4+j]);
vertices[0][0]=window_width*j/4+marg; vertices[0][1]=window_height*i/4+marg;
vertices[0][2]=0.0f;
vertices[1][0]=window_width*j/4+marg; vertices[1][1]=window_height*(i+1)/4-marg;
vertices[1][2]=0.0f;
vertices[2][0]=window_width*(j+1)/4-marg; vertices[2][1]=window_height*i/4+marg;
vertices[2][2]=0.0f;
vertices[3][0]=window_width*(j+1)/4-marg; vertices[3][1]=window_height*(i+1)/4-marg;
vertices[3][2]=0.0f;
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
}
}
/* Disable Vertex Pointer */
glDisableClientState(GL_VERTEX_ARRAY);
/* Disable Texture Coordinations Pointer */
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
/* Switch To A Perspective View */
ViewPerspective();
/* Enable Depth Testing */
glEnable(GL_DEPTH_TEST);
/* Disable 2D Texture Mapping */
glDisable(GL_TEXTURE_2D);
/* Disable Blending */
glDisable(GL_BLEND);
/* Unbind The Blur Texture */
glBindTexture(GL_TEXTURE_2D, 0);
}
void fxRadialBlur(int fxtype,int _ww,int _hh,short int *spectrumDataL,short int *spectrumDataR,int numval,float alphaval) {
/* Set The Clear Color To Black */
glClearColor(0.0f, 0.0f, 0.0f, alphaval);
/* Clear Screen And Depth Buffer */
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
/* Reset The View */
glLoadIdentity();
switch (fxtype) {
case 0:
ProcessSpectrum(_ww,_hh,spectrumDataL,spectrumDataR,numval);
break;
/*case 1:
DrawBlur1(0.95f,0.009f, _ww, _hh);
ProcessSpectrum(_ww,_hh,spectrumDataL,spectrumDataR,numval);
glBindTexture(GL_TEXTURE_2D, FxTexture);
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 512, 512, 0);
glBindTexture(GL_TEXTURE_2D, 0);
break;*/
case 1:
/*RenderToTexture(_ww, _hh,spectrumDataL,spectrumDataR,numval);
ProcessSpectrum(_ww,_hh,spectrumDataL,spectrumDataR,numval);
DrawBlur(8, 0.04f, _ww, _hh);*/
break;
}
glFlush();
}
/**************************************************/
/**************************************************/
/**************************************************/
-(void)updateFlagOnExit{
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
NSNumber *valNb;
valNb=[[NSNumber alloc] initWithInt:0];
[prefs setObject:valNb forKey:@"ModizerRunning"];[valNb autorelease];
[prefs synchronize];
[valNb autorelease];
}
//return 1 if flag is not ok
-(int)checkFlagOnStartup{
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
NSNumber *valNb;
int retcode=0;
valNb=[prefs objectForKey:@"ModizerRunning"];if (DEBUG_NO_SETTINGS) valNb=nil;
if (valNb == nil) retcode=1;
else if ([valNb intValue]!=0) retcode=1;
valNb=[[NSNumber alloc] initWithInt:1];
[prefs setObject:valNb forKey:@"ModizerRunning"];[valNb autorelease];
return retcode;
}
-(void) updateAllSettingsAfterChange {
/////////////////////////////////////
//update according to settings
if (oglViewFullscreen) {
oglViewFullscreen=0;
[self oglViewSwitchFS];
}
mLoopMode--;
[self changeLoopMode];
[mplayer setLoopInf:mplayer.mLoopMode^1];
[self pushedLoopInf];
mShuffle^=1;
[self shuffle];
//update settings according toi what was loaded
[self optUADE_Led];
[self optUADE_Norm];
[self optUADE_PostFX];
[self optUADE_Pan];
[self optUADE_Head];
[self optUADE_Gain];
[self optUADE_PanValue];
[self optUADE_GainValue];
[self optGEN_DefaultLength];
[self optTIM_Polyphony];
[self optFX_Alpha];
[self optSID_Optim];
[self optSID_LibVersion];
[self optSID_Filter];
[self optDUMBMastVol];
[self optDUMBResampling];
[self optAOSDK_DSFEmuRatio];
[self optAOSDK_DSFDSP];
[self optAOSDK_SSFEmuRatio];
[self optAOSDK_SSFDSP];
[self optGLOB_Panning];
[self optGLOB_PanningValue];
[self settingsChanged:nil];
}
-(void) loadDefaultSettings {
///////////////////////////////////
// General
///////////////////////////////////////
sc_titleFilename.selectedSegmentIndex = 0;
sc_StatsUpload.selectedSegmentIndex = 1;
sc_SpokenTitle.selectedSegmentIndex = 1;
sc_bgPlay.selectedSegmentIndex = 1;
sc_showDebug.selectedSegmentIndex = 0;
sc_cflow.selectedSegmentIndex = 1;
sldFxAlpha.value = (mSlowDevice?1.0f:0.5f);
// segcont_resumeLaunch.selectedSegmentIndex = 0;
segcont_oscillo.selectedSegmentIndex = 0;
segcont_spectrum.selectedSegmentIndex = 0;
segcont_fx1.selectedSegmentIndex = 0;
segcont_fx2.selectedSegmentIndex = 0;
segcont_fx3.selectedSegmentIndex = 0;
segcont_fx4.selectedSegmentIndex = 0;
segcont_fx5.selectedSegmentIndex = 0;
segcont_FxBeat.selectedSegmentIndex = 0;
segcont_randFx.selectedSegmentIndex = 0;
sc_FXDetail.selectedSegmentIndex = 0;
segcont_forceMono.selectedSegmentIndex = 0;
sc_checkBeforeRedownload.selectedSegmentIndex = 0;
sc_AfterDownload.selectedSegmentIndex = 1;
sc_EnqueueMode.selectedSegmentIndex = 2;
sc_DefaultAction.selectedSegmentIndex = 0;
sc_defaultMODplayer.selectedSegmentIndex = 0;
sc_PlayerViewOnPlay.selectedSegmentIndex = 0;
///////////////////////////////////
// UADE
///////////////////////////////////////
sc_UADE_Led.selectedSegmentIndex = 0;
sc_UADE_Norm.selectedSegmentIndex = 0;
sc_UADE_PostFX.selectedSegmentIndex = 1;
sc_UADE_Head.selectedSegmentIndex = 0;
sc_UADE_Pan.selectedSegmentIndex = 1;
sc_UADE_Gain.selectedSegmentIndex = 0;
sld_UADEpan.value = 0.7f;
sld_UADEgain.value = 0.5f;
////////////////////////////////////
// SID
///////////////////////////////////////
sc_SID_Optim.selectedSegmentIndex = 1;
sc_SID_LibVersion.selectedSegmentIndex = (mSlowDevice?0:1);
sc_SID_Filter.selectedSegmentIndex = (mSlowDevice?0:1);
////////////////////////////////////
// SexyPSF
///////////////////////////////////////
sc_SEXYPSF_Reverb.selectedSegmentIndex = 2;
sc_SEXYPSF_Interpol.selectedSegmentIndex = 2;
////////////////////////////////////
// AOSDK
///////////////////////////////////////
sc_AOSDK_Reverb.selectedSegmentIndex = 1;
sc_AOSDK_Interpol.selectedSegmentIndex = 2;
sc_AOSDKDSFDSP.selectedSegmentIndex = 0;
sc_AOSDKDSFEmuRatio.selectedSegmentIndex = 2;
sc_AOSDKSSFDSP.selectedSegmentIndex = 0;
sc_AOSDKSSFEmuRatio.selectedSegmentIndex = 2;
////////////////////////////////////
// ADPLUG
///////////////////////////////////////
sc_ADPLUG_opltype.selectedSegmentIndex = 1;
////////////////////////////////////
// GME
///////////////////////////////////////
////////////////////////////////////
// TIMIDITY
///////////////////////////////////////
sc_TIMchorus.selectedSegmentIndex = (mSlowDevice? 0:1);
sc_TIMreverb.selectedSegmentIndex = (mSlowDevice? 0:1);
sc_TIMfilter.selectedSegmentIndex = (mSlowDevice? 0:1);
sc_TIMresample.selectedSegmentIndex = (mSlowDevice? 0:1);
sld_TIMPoly.value = (mSlowDevice? 64:128);
////////////////////////////////////
// MODPLUG
///////////////////////////////////////
segcont_shownote.selectedSegmentIndex = 0;
mastVolSld.value = 0.5f;
segcont_mpSampling.selectedSegmentIndex = 0;
segcont_mpMB.selectedSegmentIndex = 0;
bassAmoSld.value = 0.7f;
bassRanSld.value = 0.3f;
segcont_mpSUR.selectedSegmentIndex = 0;
surDepSld.value = 0.9f;
surDelSld.value = 0.8f;
segcont_mpReverb.selectedSegmentIndex = 0;
revDepSld.value = 0.8f;
revDelSld.value = 0.7f;
mpPanningSld.value = 0.5f;
[self updateAllSettingsAfterChange];
}
-(void) loadHighSettings {
///////////////////////////////////
// General
///////////////////////////////////////
sc_titleFilename.selectedSegmentIndex = 0;
sc_StatsUpload.selectedSegmentIndex = 1;
sc_SpokenTitle.selectedSegmentIndex = 1;
sc_bgPlay.selectedSegmentIndex = 2;
sc_showDebug.selectedSegmentIndex = 0;
sc_cflow.selectedSegmentIndex = 1;
sldFxAlpha.value = 0.5f;
sc_Panning.selectedSegmentIndex=0;
sldPanning.value = 0.7f;
// segcont_resumeLaunch.selectedSegmentIndex = 0;
segcont_oscillo.selectedSegmentIndex = 2;
segcont_spectrum.selectedSegmentIndex = 1;
segcont_fx1.selectedSegmentIndex = 0;
segcont_fx2.selectedSegmentIndex = 0;
segcont_fx3.selectedSegmentIndex = 0;
segcont_fx4.selectedSegmentIndex=0;
segcont_fx5.selectedSegmentIndex = 0;
segcont_FxBeat.selectedSegmentIndex = 0;
segcont_randFx.selectedSegmentIndex = 0;
sc_FXDetail.selectedSegmentIndex = 2;
segcont_forceMono.selectedSegmentIndex = 0;
sc_checkBeforeRedownload.selectedSegmentIndex = 0;
sc_AfterDownload.selectedSegmentIndex = 1;
sc_EnqueueMode.selectedSegmentIndex = 2;
sc_DefaultAction.selectedSegmentIndex = 0;
sc_defaultMODplayer.selectedSegmentIndex = 1;
sc_PlayerViewOnPlay.selectedSegmentIndex = 1;
///////////////////////////////////
// UADE
///////////////////////////////////////
sc_UADE_Led.selectedSegmentIndex = 0;
sc_UADE_Norm.selectedSegmentIndex = 0;
sc_UADE_PostFX.selectedSegmentIndex = 1;
sc_UADE_Head.selectedSegmentIndex = 0;
sc_UADE_Pan.selectedSegmentIndex = 1;
sc_UADE_Gain.selectedSegmentIndex = 0;
sld_UADEpan.value = 0.7f;
sld_UADEgain.value = 0.5f;
////////////////////////////////////
// SID
///////////////////////////////////////
sc_SID_Optim.selectedSegmentIndex = 1;
sc_SID_LibVersion.selectedSegmentIndex = 1;
sc_SID_Filter.selectedSegmentIndex = 1;
////////////////////////////////////
// SexyPSF
///////////////////////////////////////
sc_SEXYPSF_Reverb.selectedSegmentIndex = 2;
sc_SEXYPSF_Interpol.selectedSegmentIndex = 2;
////////////////////////////////////
// AOSDK
///////////////////////////////////////
sc_AOSDK_Reverb.selectedSegmentIndex = 1;
sc_AOSDK_Interpol.selectedSegmentIndex = 2;
sc_AOSDKDSFDSP.selectedSegmentIndex = 1;
sc_AOSDKDSFEmuRatio.selectedSegmentIndex = 0;
sc_AOSDKSSFDSP.selectedSegmentIndex = 1;
sc_AOSDKSSFEmuRatio.selectedSegmentIndex = 0;
////////////////////////////////////
// ADPLUG
///////////////////////////////////////
sc_ADPLUG_opltype.selectedSegmentIndex = 1;
////////////////////////////////////
// GME
///////////////////////////////////////
////////////////////////////////////
// DUMB
///////////////////////////////////////
sc_DUMBResampling.selectedSegmentIndex = 2;
sldDUMBMastVol.value = 0.5f;
////////////////////////////////////
// TIMIDITY
///////////////////////////////////////
sc_TIMchorus.selectedSegmentIndex = 1;
sc_TIMreverb.selectedSegmentIndex = 1;
sc_TIMfilter.selectedSegmentIndex = 1;
sc_TIMresample.selectedSegmentIndex = 3;
sld_TIMPoly.value = 256;
////////////////////////////////////
// MODPLUG
///////////////////////////////////////
segcont_shownote.selectedSegmentIndex = 1;
mastVolSld.value = 0.5f;
segcont_mpSampling.selectedSegmentIndex = 2;
segcont_mpMB.selectedSegmentIndex = 0;
bassAmoSld.value = 0.7f;
bassRanSld.value = 0.3f;
segcont_mpSUR.selectedSegmentIndex = 0;
surDepSld.value = 0.9f;
surDelSld.value = 0.8f;
segcont_mpReverb.selectedSegmentIndex = 0;
revDepSld.value = 0.8f;
revDelSld.value = 0.7f;
mpPanningSld.value = 0.5f;
[self updateAllSettingsAfterChange];
}
-(void) loadMedSettings {
///////////////////////////////////
// General
///////////////////////////////////////
sc_titleFilename.selectedSegmentIndex = 0;
sc_StatsUpload.selectedSegmentIndex = 1;
sc_SpokenTitle.selectedSegmentIndex = 0;
sc_bgPlay.selectedSegmentIndex = 1;
sc_showDebug.selectedSegmentIndex = 0;
sc_cflow.selectedSegmentIndex = 1;
sldFxAlpha.value = 0.5f;
sc_Panning.selectedSegmentIndex=0;
sldPanning.value = 0.7f;
// segcont_resumeLaunch.selectedSegmentIndex = 0;
segcont_oscillo.selectedSegmentIndex = 0;
segcont_spectrum.selectedSegmentIndex = 0;
segcont_fx1.selectedSegmentIndex = 0;
segcont_fx2.selectedSegmentIndex = 0;
segcont_fx3.selectedSegmentIndex = 0;
segcont_fx4.selectedSegmentIndex=0;
segcont_fx5.selectedSegmentIndex = 0;
segcont_FxBeat.selectedSegmentIndex = 0;
segcont_randFx.selectedSegmentIndex = 0;
sc_FXDetail.selectedSegmentIndex = 1;
segcont_forceMono.selectedSegmentIndex = 0;
sc_checkBeforeRedownload.selectedSegmentIndex = 0;
sc_AfterDownload.selectedSegmentIndex = 1;
sc_EnqueueMode.selectedSegmentIndex = 2;
sc_DefaultAction.selectedSegmentIndex = 0;
sc_defaultMODplayer.selectedSegmentIndex = 0;
sc_PlayerViewOnPlay.selectedSegmentIndex = 1;
///////////////////////////////////
// UADE
///////////////////////////////////////
sc_UADE_Led.selectedSegmentIndex = 0;
sc_UADE_Norm.selectedSegmentIndex = 0;
sc_UADE_PostFX.selectedSegmentIndex = 1;
sc_UADE_Head.selectedSegmentIndex = 0;
sc_UADE_Pan.selectedSegmentIndex = 1;
sc_UADE_Gain.selectedSegmentIndex = 0;
sld_UADEpan.value = 0.7f;
sld_UADEgain.value = 0.5f;
////////////////////////////////////
// SID
///////////////////////////////////////
sc_SID_Optim.selectedSegmentIndex = 1;
sc_SID_LibVersion.selectedSegmentIndex = 1;
sc_SID_Filter.selectedSegmentIndex = 1;
////////////////////////////////////
// SexyPSF
///////////////////////////////////////
sc_SEXYPSF_Reverb.selectedSegmentIndex = 2;
sc_SEXYPSF_Interpol.selectedSegmentIndex = 2;
////////////////////////////////////
// AOSDK
///////////////////////////////////////
sc_AOSDK_Reverb.selectedSegmentIndex = 1;
sc_AOSDK_Interpol.selectedSegmentIndex = 1;
sc_AOSDKDSFDSP.selectedSegmentIndex = 0;
sc_AOSDKDSFEmuRatio.selectedSegmentIndex = 2;
sc_AOSDKSSFDSP.selectedSegmentIndex = 0;
sc_AOSDKSSFEmuRatio.selectedSegmentIndex = 2;
////////////////////////////////////
// ADPLUG
///////////////////////////////////////
sc_ADPLUG_opltype.selectedSegmentIndex = 1;
////////////////////////////////////
// GME
///////////////////////////////////////
////////////////////////////////////
// DUMB
///////////////////////////////////////
sc_DUMBResampling.selectedSegmentIndex = 1;
sldDUMBMastVol.value = 0.5f;
////////////////////////////////////
// TIMIDITY
///////////////////////////////////////
sc_TIMchorus.selectedSegmentIndex = 1;
sc_TIMreverb.selectedSegmentIndex = 1;
sc_TIMfilter.selectedSegmentIndex = 1;
sc_TIMresample.selectedSegmentIndex = 3;
sld_TIMPoly.value = 128;
////////////////////////////////////
// MODPLUG
///////////////////////////////////////
segcont_shownote.selectedSegmentIndex = 1;
mastVolSld.value = 0.5f;
segcont_mpSampling.selectedSegmentIndex = 0;
segcont_mpMB.selectedSegmentIndex = 0;
bassAmoSld.value = 0.7f;
bassRanSld.value = 0.3f;
segcont_mpSUR.selectedSegmentIndex = 0;
surDepSld.value = 0.9f;
surDelSld.value = 0.8f;
segcont_mpReverb.selectedSegmentIndex = 0;
revDepSld.value = 0.8f;
revDelSld.value = 0.7f;
mpPanningSld.value = 0.5f;
[self updateAllSettingsAfterChange];
}
-(void) loadLowSettings {
///////////////////////////////////
// General
///////////////////////////////////////
sc_titleFilename.selectedSegmentIndex = 0;
sc_StatsUpload.selectedSegmentIndex = 1;
sc_SpokenTitle.selectedSegmentIndex = 0;
sc_bgPlay.selectedSegmentIndex = 0;
sc_showDebug.selectedSegmentIndex = 0;
sc_cflow.selectedSegmentIndex = 1;
sldFxAlpha.value = 1.0f;
sc_Panning.selectedSegmentIndex=0;
sldPanning.value = 0.7f;
// segcont_resumeLaunch.selectedSegmentIndex = 0;
segcont_oscillo.selectedSegmentIndex = 0;
segcont_spectrum.selectedSegmentIndex = 0;
segcont_fx1.selectedSegmentIndex = 0;
segcont_fx2.selectedSegmentIndex = 0;
segcont_fx3.selectedSegmentIndex = 0;
segcont_fx4.selectedSegmentIndex=0;
segcont_fx5.selectedSegmentIndex = 0;
segcont_FxBeat.selectedSegmentIndex = 0;
segcont_randFx.selectedSegmentIndex = 0;
sc_FXDetail.selectedSegmentIndex = 0;
segcont_forceMono.selectedSegmentIndex = 0;
sc_checkBeforeRedownload.selectedSegmentIndex = 0;
sc_AfterDownload.selectedSegmentIndex = 1;
sc_EnqueueMode.selectedSegmentIndex = 2;
sc_DefaultAction.selectedSegmentIndex = 0;
sc_defaultMODplayer.selectedSegmentIndex = 0;
sc_PlayerViewOnPlay.selectedSegmentIndex = 0;
///////////////////////////////////
// UADE
///////////////////////////////////////
sc_UADE_Led.selectedSegmentIndex = 0;
sc_UADE_Norm.selectedSegmentIndex = 0;
sc_UADE_PostFX.selectedSegmentIndex = 0;
sc_UADE_Head.selectedSegmentIndex = 0;
sc_UADE_Pan.selectedSegmentIndex = 0;
sc_UADE_Gain.selectedSegmentIndex = 0;
sld_UADEpan.value = 0.7f;
sld_UADEgain.value = 0.5f;
////////////////////////////////////
// SID
///////////////////////////////////////
sc_SID_Optim.selectedSegmentIndex = 2;
sc_SID_LibVersion.selectedSegmentIndex = 0;
sc_SID_Filter.selectedSegmentIndex = 0;
////////////////////////////////////
// SexyPSF
///////////////////////////////////////
sc_SEXYPSF_Reverb.selectedSegmentIndex = 0;
sc_SEXYPSF_Interpol.selectedSegmentIndex = 0;
////////////////////////////////////
// AOSDK
///////////////////////////////////////
sc_AOSDK_Reverb.selectedSegmentIndex = 0;
sc_AOSDK_Interpol.selectedSegmentIndex = 0;
sc_AOSDKDSFDSP.selectedSegmentIndex = 0;
sc_AOSDKDSFEmuRatio.selectedSegmentIndex = 3;
sc_AOSDKSSFDSP.selectedSegmentIndex = 0;
sc_AOSDKSSFEmuRatio.selectedSegmentIndex = 3;
////////////////////////////////////
// ADPLUG
///////////////////////////////////////
sc_ADPLUG_opltype.selectedSegmentIndex = 0;
////////////////////////////////////
// GME
///////////////////////////////////////
////////////////////////////////////
// DUMB
///////////////////////////////////////
sc_DUMBResampling.selectedSegmentIndex = 0;
sldDUMBMastVol.value = 0.5f;
////////////////////////////////////
// TIMIDITY
///////////////////////////////////////
sc_TIMchorus.selectedSegmentIndex = 0;
sc_TIMreverb.selectedSegmentIndex = 0;
sc_TIMfilter.selectedSegmentIndex = 0;
sc_TIMresample.selectedSegmentIndex = 0;
sld_TIMPoly.value = 64;
////////////////////////////////////
// MODPLUG
///////////////////////////////////////
segcont_shownote.selectedSegmentIndex = 0;
mastVolSld.value = 0.5f;
segcont_mpSampling.selectedSegmentIndex = 3;
segcont_mpMB.selectedSegmentIndex = 0;
bassAmoSld.value = 0.7f;
bassRanSld.value = 0.3f;
segcont_mpSUR.selectedSegmentIndex = 0;
surDepSld.value = 0.9f;
surDelSld.value = 0.8f;
segcont_mpReverb.selectedSegmentIndex = 0;
revDepSld.value = 0.8f;
revDelSld.value = 0.7f;
mpPanningSld.value = 0.5f;
[self updateAllSettingsAfterChange];
}
-(void)loadSettings:(int)safe_mode{
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
NSNumber *valNb;
int not_expected_version;
///////////////////////////////////
// General
///////////////////////////////////////
not_expected_version=0;
valNb=[prefs objectForKey:@"VERSION_MAJOR"];if (safe_mode) valNb=nil;
if (valNb == nil) {
//should not happen on released version
not_expected_version=0;
} else {
if ([valNb intValue]!=VERSION_MAJOR) {
not_expected_version=1;
}
}
valNb=[prefs objectForKey:@"VERSION_MINOR"];if (safe_mode) valNb=nil;
if (valNb == nil) {
//should not happen on released version
not_expected_version=0;
} else {
if ([valNb intValue]!=VERSION_MINOR) {
not_expected_version=1;
}
}
if (not_expected_version) {
//do some stuff, like reset/upgrade DB, ...
}
valNb=[prefs objectForKey:@"ViewFX"];if (safe_mode) valNb=nil;
if (valNb == nil) mOglViewIsHidden=YES;
else mOglViewIsHidden = [valNb boolValue];
valNb=[prefs objectForKey:@"StatsUpload"];if (safe_mode) valNb=nil;
if (valNb == nil) sc_StatsUpload.selectedSegmentIndex = 1;
else sc_StatsUpload.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"SpokenTitle"];if (safe_mode) valNb=nil;
if (valNb == nil) sc_SpokenTitle.selectedSegmentIndex = 1;
else sc_SpokenTitle.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"BGPlayback"];if (safe_mode) valNb=nil;
if (valNb == nil) sc_bgPlay.selectedSegmentIndex = 1;
else sc_bgPlay.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"TitleFilename"];if (safe_mode) valNb=nil;
if (valNb == nil) sc_titleFilename.selectedSegmentIndex = 0;
else sc_titleFilename.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"ShowDebugInfos"];if (safe_mode) valNb=nil;
if (valNb == nil) sc_showDebug.selectedSegmentIndex = 0;
else sc_showDebug.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"Coverflow"];if (safe_mode) valNb=nil;
if (valNb == nil) sc_cflow.selectedSegmentIndex = 1;
else sc_cflow.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"FXAlpha"];if (safe_mode) valNb=nil;
if (valNb == nil) sldFxAlpha.value = (mSlowDevice?1.0f:0.5f);
else sldFxAlpha.value = [valNb floatValue];
valNb=[prefs objectForKey:@"GLOBPanning"];if (safe_mode) valNb=nil;
if (valNb == nil) sc_Panning.selectedSegmentIndex=0;
else sc_Panning.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"GLOBPanningValue"];if (safe_mode) valNb=nil;
if (valNb == nil) sldPanning.value = 0.7f;
else sldPanning.value = [valNb floatValue];
// valNb=[prefs objectForKey:@"ResumeOnLaunch"];if (safe_mode) valNb=nil;
// if (valNb == nil) segcont_resumeLaunch.selectedSegmentIndex = 0;
// else segcont_resumeLaunch.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"Oscillo"];if (safe_mode) valNb=nil;
if (valNb == nil) segcont_oscillo.selectedSegmentIndex = 0;
else segcont_oscillo.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"2DSpectrum"];if (safe_mode) valNb=nil;
if (valNb == nil) segcont_spectrum.selectedSegmentIndex = 0;
else segcont_spectrum.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"3DFX1"];if (safe_mode) valNb=nil;
if (valNb == nil) segcont_fx1.selectedSegmentIndex = 0;
else segcont_fx1.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"3DFX2"];if (safe_mode) valNb=nil;
if (valNb == nil) segcont_fx2.selectedSegmentIndex = 0;
else segcont_fx2.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"3DFX3"];if (safe_mode) valNb=nil;
if (valNb == nil) segcont_fx3.selectedSegmentIndex = 0;
else segcont_fx3.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"FX4"];if (safe_mode) valNb=nil;
if (valNb == nil) segcont_fx4.selectedSegmentIndex = 0;
else segcont_fx4.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"FX5"];if (safe_mode) valNb=nil;
if (valNb == nil) segcont_fx5.selectedSegmentIndex = 0;
else segcont_fx5.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"FXBEAT"];if (safe_mode) valNb=nil;
if (valNb == nil) segcont_FxBeat.selectedSegmentIndex = 0;
else segcont_FxBeat.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"RandomFX"];if (safe_mode) valNb=nil;
if (valNb == nil) segcont_randFx.selectedSegmentIndex = 0;
else segcont_randFx.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"FXDetail"];if (safe_mode) valNb=nil;
if (valNb == nil) sc_FXDetail.selectedSegmentIndex = 0;
else sc_FXDetail.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"ForceMono"];if (safe_mode) valNb=nil;
if (valNb == nil) segcont_forceMono.selectedSegmentIndex = 0;
else segcont_forceMono.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"AllowRedownload"];if (safe_mode) valNb=nil;
if (valNb == nil) sc_checkBeforeRedownload.selectedSegmentIndex = 0;
else sc_checkBeforeRedownload.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"AfterDownload"];if (safe_mode) valNb=nil;
if (valNb == nil) sc_AfterDownload.selectedSegmentIndex = 1;
else sc_AfterDownload.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"EnqueueMode"];if (safe_mode) valNb=nil;
if (valNb == nil) sc_EnqueueMode.selectedSegmentIndex = 2;
else sc_EnqueueMode.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"DefaultAction"];if (safe_mode) valNb=nil;
if (valNb == nil) sc_DefaultAction.selectedSegmentIndex = 0;
else sc_DefaultAction.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"DefaultMODplayer"];if (safe_mode) valNb=nil;
if (valNb == nil) sc_defaultMODplayer.selectedSegmentIndex = 0;
else sc_defaultMODplayer.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"PlayerViewOnPlay"];if (safe_mode) valNb=nil;
if (valNb == nil) sc_PlayerViewOnPlay.selectedSegmentIndex = 0;
else sc_PlayerViewOnPlay.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"DefaultLength"];if (safe_mode) valNb=nil;
if (valNb == nil) sld_DefaultLength.value = SONG_DEFAULT_LENGTH;
else sld_DefaultLength.value = [valNb floatValue];
///////////////////////////////////
// UADE
///////////////////////////////////////
valNb=[prefs objectForKey:@"UADE_LED"];if (safe_mode) valNb=nil;
if (valNb == nil) sc_UADE_Led.selectedSegmentIndex = 0;
else sc_UADE_Led.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"UADE_NORM"];if (safe_mode) valNb=nil;
if (valNb == nil) sc_UADE_Norm.selectedSegmentIndex = 0;
else sc_UADE_Norm.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"UADE_POSTFX"];if (safe_mode) valNb=nil;
if (valNb == nil) sc_UADE_PostFX.selectedSegmentIndex = 1;
else sc_UADE_PostFX.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"UADE_HEAD"];if (safe_mode) valNb=nil;
if (valNb == nil) sc_UADE_Head.selectedSegmentIndex = 0;
else sc_UADE_Head.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"UADE_PAN"];if (safe_mode) valNb=nil;
if (valNb == nil) sc_UADE_Pan.selectedSegmentIndex = 1;
else sc_UADE_Pan.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"UADE_GAIN"];if (safe_mode) valNb=nil;
if (valNb == nil) sc_UADE_Gain.selectedSegmentIndex = 0;
else sc_UADE_Gain.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"UADE_PANVAL"];if (safe_mode) valNb=nil;
if (valNb == nil) sld_UADEpan.value = 0.7f;
else sld_UADEpan.value = [valNb floatValue];
valNb=[prefs objectForKey:@"UADE_GAINVAL"];if (safe_mode) valNb=nil;
if (valNb == nil) sld_UADEgain.value = 0.5f;
else sld_UADEgain.value = [valNb floatValue];
////////////////////////////////////
// SID
///////////////////////////////////////
valNb=[prefs objectForKey:@"SIDOptim"];if (safe_mode) valNb=nil;
if (valNb == nil) sc_SID_Optim.selectedSegmentIndex = 1;
else sc_SID_Optim.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"SIDLibVersion"];if (safe_mode) valNb=nil;
if (valNb == nil) sc_SID_LibVersion.selectedSegmentIndex = (mSlowDevice?0:1);
else sc_SID_LibVersion.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"SIDFilter"];if (safe_mode) valNb=nil;
if (valNb == nil) sc_SID_Filter.selectedSegmentIndex = (mSlowDevice?0:1);
else sc_SID_Filter.selectedSegmentIndex = [valNb intValue];
////////////////////////////////////
// SexyPSF
///////////////////////////////////////
valNb=[prefs objectForKey:@"SexyPSFReverb"];if (safe_mode) valNb=nil;
if (valNb == nil) sc_SEXYPSF_Reverb.selectedSegmentIndex = 2;
else sc_SEXYPSF_Reverb.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"SexyPSFInterp"];if (safe_mode) valNb=nil;
if (valNb == nil) sc_SEXYPSF_Interpol.selectedSegmentIndex = 2;
else sc_SEXYPSF_Interpol.selectedSegmentIndex = [valNb intValue];
////////////////////////////////////
// AOSDK
///////////////////////////////////////
valNb=[prefs objectForKey:@"AOSDKReverb"];if (safe_mode) valNb=nil;
if (valNb == nil) sc_AOSDK_Reverb.selectedSegmentIndex = 1;
else sc_AOSDK_Reverb.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"AOSDKInterp"];if (safe_mode) valNb=nil;
if (valNb == nil) sc_AOSDK_Interpol.selectedSegmentIndex = 2;
else sc_AOSDK_Interpol.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"AOSDKDSFDSP"];if (safe_mode) valNb=nil;
if (valNb == nil) sc_AOSDKDSFDSP.selectedSegmentIndex = 0;
else sc_AOSDKDSFDSP.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"AOSDKDSFEmuRatio"];if (safe_mode) valNb=nil;
if (valNb == nil) sc_AOSDKDSFEmuRatio.selectedSegmentIndex = 2;
else sc_AOSDKDSFEmuRatio.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"AOSDKSSFDSP"];if (safe_mode) valNb=nil;
if (valNb == nil) sc_AOSDKSSFDSP.selectedSegmentIndex = 0;
else sc_AOSDKSSFDSP.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"AOSDKSSFEmuRatio"];if (safe_mode) valNb=nil;
if (valNb == nil) sc_AOSDKSSFEmuRatio.selectedSegmentIndex = 2;
else sc_AOSDKSSFEmuRatio.selectedSegmentIndex = [valNb intValue];
////////////////////////////////////
// ADPLUG
///////////////////////////////////////
valNb=[prefs objectForKey:@"ADPLUGopltype"];if (safe_mode) valNb=nil;
if (valNb == nil) sc_ADPLUG_opltype.selectedSegmentIndex = 1;
else sc_ADPLUG_opltype.selectedSegmentIndex = [valNb intValue];
////////////////////////////////////
// GME
///////////////////////////////////////
////////////////////////////////////
// DUMB
///////////////////////////////////////
valNb=[prefs objectForKey:@"DUMBResampling"];if (safe_mode) valNb=nil;
if (valNb == nil) sc_DUMBResampling.selectedSegmentIndex = (mSlowDevice? 0:2);
else sc_DUMBResampling.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"DUMBMastVol"];if (safe_mode) valNb=nil;
if (valNb == nil) sldDUMBMastVol.value = 0.5f;
else sldDUMBMastVol.value = [valNb floatValue];
////////////////////////////////////
// TIMIDITY
///////////////////////////////////////
valNb=[prefs objectForKey:@"TIMChorus"];if (safe_mode) valNb=nil;
if (valNb == nil) sc_TIMchorus.selectedSegmentIndex = (mSlowDevice? 0:1);
else sc_TIMchorus.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"TIMReverb"];if (safe_mode) valNb=nil;
if (valNb == nil) sc_TIMreverb.selectedSegmentIndex = (mSlowDevice? 0:1);
else sc_TIMreverb.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"TIMFilter"];if (safe_mode) valNb=nil;
if (valNb == nil) sc_TIMfilter.selectedSegmentIndex = (mSlowDevice? 0:1);
else sc_TIMfilter.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"TIMResample"];if (safe_mode) valNb=nil;
if (valNb == nil) sc_TIMresample.selectedSegmentIndex = (mSlowDevice? 0:1);
else sc_TIMresample.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"TIMPoly"];if (safe_mode) valNb=nil;
if (valNb == nil) sld_TIMPoly.value = (mSlowDevice? 64:128);
else sld_TIMPoly.value = [valNb intValue];
////////////////////////////////////
// MODPLUG
///////////////////////////////////////
valNb=[prefs objectForKey:@"ShowNotes"];if (safe_mode) valNb=nil;
if (valNb == nil) segcont_shownote.selectedSegmentIndex = 0;
else segcont_shownote.selectedSegmentIndex = [valNb intValue];
valNb=[prefs objectForKey:@"MasterVol"];if (safe_mode) valNb=nil;
if (valNb == nil) mastVolSld.value = 0.5f;
else mastVolSld.value = [valNb floatValue];
valNb=[prefs objectForKey:@"Resampling"];if (safe_mode) valNb=nil;