-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathC700Kernel.cpp
2066 lines (1782 loc) · 62.9 KB
/
C700Kernel.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* C700Kernel.cpp
* C700
*
* Created by osoumen on 12/10/12.
* Copyright 2012 __MyCompanyName__. All rights reserved.
*
*/
#include "XIFile.h"
#include "C700Kernel.h"
#include "samplebrr.h"
#include <math.h>
#if MAC
#include "macOSUtils.h"
#else
#include <Shlobj.h>
#endif
void CalcFIRParam( const float band[5], int filter[8] );
//-----------------------------------------------------------------------------
C700Kernel::C700Kernel()
: C700Parameters(kNumberOfParameters)
, propertyNotifyFunc(NULL)
, propNotifyUserData(NULL)
, parameterSetFunc(NULL)
, paramSetUserData(NULL)
, mCodeFile(NULL)
, mGlobalSettingsHasChanged(false)
{
createPropertyParamMap(mPropertyParams);
for ( int i=0; i<kNumberOfParameters; i++ ) {
SetParameter(i, GetParameterDefault(i));
}
for (int i=0; i<5; i++) {
mFilterBand[i] = 1.0f;
}
mEditProg = 0;
mEditChannel = 0;
mIsHwAvailable = false;
mInRestoreParameters = false;
mCurrentPosInTimeLine = .0;
mRecordStartBeatPos = .0;
mRecordLoopStartBeatPos = .0;
mRecordEndBeatPos = .0;
mIsPlaying = false;
mSampleRate = 44100.0;
// ノートオンインジケータ初期化
for ( int i=0; i<16; i++ ) {
mOnNotes[i] = 0;
mMaxNote[i] = 0;
}
mTotalOnNotes = 0;
//プログラムの初期化
for (int i=0; i<128; i++) {
mVPset[i].pgname[0] = 0;
//mVPset[i].releaseBrr(); // BRRDataのコンストラクタで初期化される
mVPset[i].basekey = 0;
mVPset[i].lowkey = 0;
mVPset[i].highkey = 0;
mVPset[i].loop = false;
mVPset[i].echo = false;
mVPset[i].bank = 0;
mVPset[i].lp = 0;
mVPset[i].rate = 32000.0f;
mVPset[i].volL = 100;
mVPset[i].volR = 100;
mVPset[i].sourceFile[0] = 0;
mVPset[i].isEmphasized = true;
mVPset[i].ar = mPropertyParams[kAudioUnitCustomProperty_AR].defaultValue;
mVPset[i].dr = mPropertyParams[kAudioUnitCustomProperty_DR].defaultValue;
mVPset[i].sl = mPropertyParams[kAudioUnitCustomProperty_SL].defaultValue;
mVPset[i].sr1 = mPropertyParams[kAudioUnitCustomProperty_SR1].defaultValue;
mVPset[i].sr2 = mPropertyParams[kAudioUnitCustomProperty_SR2].defaultValue;
mVPset[i].sustainMode = mPropertyParams[kAudioUnitCustomProperty_SustainMode].defaultValue!=0?true:false;
mVPset[i].monoMode = mPropertyParams[kAudioUnitCustomProperty_MonoMode].defaultValue!=0?true:false;
mVPset[i].portamentoOn = mPropertyParams[kAudioUnitCustomProperty_PortamentoOn].defaultValue!=0?true:false;
mVPset[i].portamentoRate = mPropertyParams[kAudioUnitCustomProperty_PortamentoRate].defaultValue;
mVPset[i].noteOnPriority = mPropertyParams[kAudioUnitCustomProperty_NoteOnPriority].defaultValue;
mVPset[i].releasePriority = mPropertyParams[kAudioUnitCustomProperty_ReleasePriority].defaultValue;
mVPset[i].pmOn = mPropertyParams[kAudioUnitCustomProperty_PitchModulationOn].defaultValue!=0?true:false;
mVPset[i].noiseOn = mPropertyParams[kAudioUnitCustomProperty_NoiseOn].defaultValue!=0?true:false;
}
restoreGlobalProperties();
// 音源にプログラムのメモリを渡す
mDriver.SetVPSet(mVPset);
}
//-----------------------------------------------------------------------------
C700Kernel::~C700Kernel()
{
if (mGlobalSettingsHasChanged) {
storeGlobalProperties();
}
for (int i=0; i<128; i++) {
mVPset[i].pgname[0] = 0;
mVPset[i].sourceFile[0] = 0;
}
}
//-----------------------------------------------------------------------------
void C700Kernel::Reset()
{
//音源リセット
mDriver.Reset();
for ( int i=0; i<16; i++ ) {
// MIDIインジケータをリセット
mOnNotes[i] = 0;
mMaxNote[i] = 0;
if ( propertyNotifyFunc ) {
propertyNotifyFunc( kAudioUnitCustomProperty_NoteOnTrack_1+i, propNotifyUserData );
propertyNotifyFunc( kAudioUnitCustomProperty_MaxNoteTrack_1+i, propNotifyUserData );
}
}
mTotalOnNotes = 0;
propertyNotifyFunc( kAudioUnitCustomProperty_MaxNoteOnTotal, propNotifyUserData );
if (mGlobalSettingsHasChanged) {
storeGlobalProperties();
}
}
//-----------------------------------------------------------------------------
void C700Kernel::SetTempo( double tempo )
{
mTempo = tempo;
}
//-----------------------------------------------------------------------------
void C700Kernel::SetCurrentSampleInTimeLine( double currentSample )
{
mCurrentPosInTimeLine = currentSample;
}
//-----------------------------------------------------------------------------
void C700Kernel::SetIsPlaying( bool isPlaying )
{
mIsPlaying = isPlaying;
}
//-----------------------------------------------------------------------------
bool C700Kernel::SetParameter( int id, float value )
{
C700Parameters::SetParameter( id, value );
switch ( id ) {
case kParam_poly:
mDriver.SetVoiceLimit(value);
break;
case kParam_mainvol_L:
mDriver.SetMainVol_L(value);
break;
case kParam_mainvol_R:
mDriver.SetMainVol_R(value);
break;
case kParam_vibdepth:
//mDriver.ModWheel(0, value);
HandleControlChange(0, 1, value, 0);
break;
case kParam_vibrate:
mDriver.SetVibFreq(-1, value); // -1が全チャンネルを表す
break;
case kParam_vibdepth2:
mDriver.SetVibDepth(-1, value); // -1は全チャンネルを表す
break;
case kParam_velocity:
switch ( (int)value ) {
case 0:
mDriver.SetVelocityMode( kVelocityMode_Constant );
break;
case 1:
mDriver.SetVelocityMode( kVelocityMode_Square );
break;
case 2:
mDriver.SetVelocityMode( kVelocityMode_Linear );
break;
default:
mDriver.SetVelocityMode( kVelocityMode_Square );
}
break;
case kParam_bendrange:
mDriver.SetPBRange(value);
break;
case kParam_program:
HandleProgramChange(0, value, 0);
break;
case kParam_engine:
switch ( (int)value ) {
case 0:
mDriver.SetEngineType(kEngineType_Old);
break;
case 1:
mDriver.SetEngineType(kEngineType_Relaxed);
break;
case 2:
mDriver.SetEngineType(kEngineType_Accurate);
break;
}
break;
case kParam_bankAmulti:
mDriver.SetMultiMode(0, value==0 ? false:true);
break;
case kParam_program_2:
case kParam_program_3:
case kParam_program_4:
case kParam_program_5:
case kParam_program_6:
case kParam_program_7:
case kParam_program_8:
case kParam_program_9:
case kParam_program_10:
case kParam_program_11:
case kParam_program_12:
case kParam_program_13:
case kParam_program_14:
case kParam_program_15:
case kParam_program_16:
HandleProgramChange( id - kParam_program_2 + 1, value, 0 );
break;
case kParam_vibdepth_2:
case kParam_vibdepth_3:
case kParam_vibdepth_4:
case kParam_vibdepth_5:
case kParam_vibdepth_6:
case kParam_vibdepth_7:
case kParam_vibdepth_8:
case kParam_vibdepth_9:
case kParam_vibdepth_10:
case kParam_vibdepth_11:
case kParam_vibdepth_12:
case kParam_vibdepth_13:
case kParam_vibdepth_14:
case kParam_vibdepth_15:
case kParam_vibdepth_16:
//mDriver.ModWheel( id - kParam_vibdepth_2 + 1, value);
HandleControlChange(id - kParam_vibdepth_2 + 1, 1, value, 0);
break;
case kParam_echovol_L:
mDriver.SetEchoVol_L( value );
break;
case kParam_echovol_R:
mDriver.SetEchoVol_R( value );
break;
case kParam_echoFB:
mDriver.SetFeedBackLevel(value);
break;
case kParam_echodelay:
mDriver.SetDelayTime(value);
break;
case kParam_fir0:
case kParam_fir1:
case kParam_fir2:
case kParam_fir3:
case kParam_fir4:
case kParam_fir5:
case kParam_fir6:
case kParam_fir7:
mDriver.SetFIRTap( id - kParam_fir0, value );
break;
case kParam_bankBmulti:
mDriver.SetMultiMode(1, value==0 ? false:true);
break;
case kParam_bankCmulti:
mDriver.SetMultiMode(2, value==0 ? false:true);
break;
case kParam_bankDmulti:
mDriver.SetMultiMode(3, value==0 ? false:true);
break;
case kParam_alwaysDelayNote:
mDriver.SetEventDelayClocks(value==0 ? 0:8192);
break;
case kParam_voiceAllocMode:
// voiceAllocモードを設定
switch ( (int)value ) {
case 0:
mDriver.SetVoiceAllocMode(kVoiceAllocMode_Oldest);
break;
case 1:
mDriver.SetVoiceAllocMode(kVoiceAllocMode_SameChannel);
break;
}
break;
case kParam_fastReleaseAsKeyOff:
mDriver.SetFastReleaseAsKeyOff(value==0 ? false:true);
break;
default:
return false;
}
return true;
}
//-----------------------------------------------------------------------------
float C700Kernel::GetParameter( int id )
{
return C700Parameters::GetParameter( id );
}
//-----------------------------------------------------------------------------
float C700Kernel::GetPropertyValue( int inID )
{
switch (inID) {
case kAudioUnitCustomProperty_Rate:
return mVPset[mEditProg].rate;
case kAudioUnitCustomProperty_BaseKey:
return mVPset[mEditProg].basekey;
case kAudioUnitCustomProperty_LowKey:
return mVPset[mEditProg].lowkey;
case kAudioUnitCustomProperty_HighKey:
return mVPset[mEditProg].highkey;
case kAudioUnitCustomProperty_LoopPoint:
return mVPset[mEditProg].lp;
case kAudioUnitCustomProperty_Loop:
return mVPset[mEditProg].loop ? 1.0f:.0f;
case kAudioUnitCustomProperty_Echo:
return mVPset[mEditProg].echo ? 1.0f:.0f;
case kAudioUnitCustomProperty_Bank:
return mVPset[mEditProg].bank;
case kAudioUnitCustomProperty_AR:
return mVPset[mEditProg].ar;
case kAudioUnitCustomProperty_DR:
return mVPset[mEditProg].dr;
case kAudioUnitCustomProperty_SL:
return mVPset[mEditProg].sl;
case kAudioUnitCustomProperty_SR1:
return mVPset[mEditProg].sr1;
case kAudioUnitCustomProperty_SR2:
return mVPset[mEditProg].sr2;
case kAudioUnitCustomProperty_VolL:
return mVPset[mEditProg].volL;
case kAudioUnitCustomProperty_VolR:
return mVPset[mEditProg].volR;
case kAudioUnitCustomProperty_EditingProgram:
return mEditProg;
case kAudioUnitCustomProperty_EditingChannel:
return mEditChannel;
case kAudioUnitCustomProperty_TotalRAM:
return GetTotalRAM();
//エコー
case kAudioUnitCustomProperty_Band1:
case kAudioUnitCustomProperty_Band2:
case kAudioUnitCustomProperty_Band3:
case kAudioUnitCustomProperty_Band4:
case kAudioUnitCustomProperty_Band5:
return mFilterBand[inID-kAudioUnitCustomProperty_Band1];
case kAudioUnitCustomProperty_NoteOnTrack_1:
case kAudioUnitCustomProperty_NoteOnTrack_2:
case kAudioUnitCustomProperty_NoteOnTrack_3:
case kAudioUnitCustomProperty_NoteOnTrack_4:
case kAudioUnitCustomProperty_NoteOnTrack_5:
case kAudioUnitCustomProperty_NoteOnTrack_6:
case kAudioUnitCustomProperty_NoteOnTrack_7:
case kAudioUnitCustomProperty_NoteOnTrack_8:
case kAudioUnitCustomProperty_NoteOnTrack_9:
case kAudioUnitCustomProperty_NoteOnTrack_10:
case kAudioUnitCustomProperty_NoteOnTrack_11:
case kAudioUnitCustomProperty_NoteOnTrack_12:
case kAudioUnitCustomProperty_NoteOnTrack_13:
case kAudioUnitCustomProperty_NoteOnTrack_14:
case kAudioUnitCustomProperty_NoteOnTrack_15:
case kAudioUnitCustomProperty_NoteOnTrack_16:
return mOnNotes[inID-kAudioUnitCustomProperty_NoteOnTrack_1];
case kAudioUnitCustomProperty_MaxNoteTrack_1:
case kAudioUnitCustomProperty_MaxNoteTrack_2:
case kAudioUnitCustomProperty_MaxNoteTrack_3:
case kAudioUnitCustomProperty_MaxNoteTrack_4:
case kAudioUnitCustomProperty_MaxNoteTrack_5:
case kAudioUnitCustomProperty_MaxNoteTrack_6:
case kAudioUnitCustomProperty_MaxNoteTrack_7:
case kAudioUnitCustomProperty_MaxNoteTrack_8:
case kAudioUnitCustomProperty_MaxNoteTrack_9:
case kAudioUnitCustomProperty_MaxNoteTrack_10:
case kAudioUnitCustomProperty_MaxNoteTrack_11:
case kAudioUnitCustomProperty_MaxNoteTrack_12:
case kAudioUnitCustomProperty_MaxNoteTrack_13:
case kAudioUnitCustomProperty_MaxNoteTrack_14:
case kAudioUnitCustomProperty_MaxNoteTrack_15:
case kAudioUnitCustomProperty_MaxNoteTrack_16:
return mMaxNote[inID-kAudioUnitCustomProperty_MaxNoteTrack_1];
case kAudioUnitCustomProperty_IsEmaphasized:
return mVPset[mEditProg].isEmphasized ? 1.0f:.0f;
case kAudioUnitCustomProperty_SustainMode:
return mVPset[mEditProg].sustainMode ? 1.0f:.0f;
case kAudioUnitCustomProperty_MonoMode:
return mVPset[mEditProg].monoMode ? 1.0f:.0f;
case kAudioUnitCustomProperty_PortamentoOn:
return mVPset[mEditProg].portamentoOn ? 1.0f:.0f;
case kAudioUnitCustomProperty_PitchModulationOn:
return mVPset[mEditProg].pmOn ? 1.0f:.0f;
case kAudioUnitCustomProperty_NoiseOn:
return mVPset[mEditProg].noiseOn ? 1.0f:.0f;
case kAudioUnitCustomProperty_PortamentoRate:
return mVPset[mEditProg].portamentoRate;
case kAudioUnitCustomProperty_NoteOnPriority:
return mVPset[mEditProg].noteOnPriority;
case kAudioUnitCustomProperty_ReleasePriority:
return mVPset[mEditProg].releasePriority;
case kAudioUnitCustomProperty_IsHwConnected:
return mDriver.GetDsp()->IsHwAvailable() ? 1.0f:.0f;
case kAudioUnitCustomProperty_RecSaveAsSpc:
return mDriver.GetDsp()->GetRecSaveAsSpc() ? 1.0f:0.f;
case kAudioUnitCustomProperty_RecSaveAsSmc:
return mDriver.GetDsp()->GetRecSaveAsSmc() ? 1.0f:0.f;
case kAudioUnitCustomProperty_TimeBaseForSmc:
{
switch (mDriver.GetDsp()->GetTimeBaseForSmc()) {
case C700DSP::SmcTimeBaseNTSC:
return 0; // NTSC
case C700DSP::SmcTimeBasePAL:
return 1;
}
}
case kAudioUnitCustomProperty_RepeatNumForSpc:
return mDriver.GetDsp()->GetRepeatNumForSpc();
case kAudioUnitCustomProperty_FadeMsTimeForSpc:
return mDriver.GetDsp()->GetFadeMsTimeForSpc();
case kAudioUnitCustomProperty_SongPlayerCodeVer:
return mDriver.GetDsp()->GetSongPlayCodeVer();
case kAudioUnitCustomProperty_HostBeatPos:
return mCurrentPosInTimeLine;
case kAudioUnitCustomProperty_MaxNoteOnTotal:
return mTotalOnNotes;
default:
return 0;
}
}
//-----------------------------------------------------------------------------
double C700Kernel::GetPropertyDoubleValue( int inID )
{
switch (inID) {
case kAudioUnitCustomProperty_Rate:
return mVPset[mEditProg].rate;
case kAudioUnitCustomProperty_RecordStartBeatPos:
return mRecordStartBeatPos;
case kAudioUnitCustomProperty_RecordLoopStartBeatPos:
return mRecordLoopStartBeatPos;
case kAudioUnitCustomProperty_RecordEndBeatPos:
return mRecordEndBeatPos;
case kAudioUnitCustomProperty_SongPlayerCodeVer:
return mDriver.GetDsp()->GetSongPlayCodeVer();
case kAudioUnitCustomProperty_HostBeatPos:
return mCurrentPosInTimeLine;
default:
return 0;
}
}
//-----------------------------------------------------------------------------
int C700Kernel::GetPropertyPtrDataSize( int inID )
{
switch (inID) {
case kAudioUnitCustomProperty_SongPlayerCode:
if (mCodeFile != NULL) {
return mCodeFile->GetDataUsed();
}
break;
case kAudioUnitCustomProperty_BRRData:
if (GetBRRData()->data == NULL) {
return 0;
}
return GetBRRData()->size;
}
return 0;
}
//-----------------------------------------------------------------------------
const void *C700Kernel::GetPropertyPtrValue( int inID )
{
switch (inID) {
#if AU
case kAudioUnitCustomProperty_PGDictionary:
{
CFDictionaryRef pgdata;
int editProg = GetPropertyValue(kAudioUnitCustomProperty_EditingProgram);
CreatePGDataDic(&pgdata, editProg);
return (void *)pgdata; //使用後要release
}
case kAudioUnitCustomProperty_XIData:
{
XIFile fileData(NULL);
fileData.SetDataFromChip(GetDriver(),
GetPropertyValue(kAudioUnitCustomProperty_EditingProgram), mTempo);
if ( fileData.IsLoaded() ) {
CFDataRef xidata;
xidata = CFDataCreate(NULL, fileData.GetDataPtr(), fileData.GetDataUsed() );
return (void *)xidata; //使用後要release
}
else {
return NULL;
}
}
#endif
case kAudioUnitCustomProperty_BRRData:
return GetBRRData()->data;
case kAudioUnitCustomProperty_SongPlayerCode:
{
if (mCodeFile != NULL) {
return mCodeFile->GetDataPtr();
}
break;
}
case kAudioUnitCustomProperty_SourceFileRef:
return GetSourceFilePath();
case kAudioUnitCustomProperty_ProgramName:
return GetProgramName();
case kAudioUnitCustomProperty_SongRecordPath:
return mDriver.GetDsp()->GetSongRecordPath();
case kAudioUnitCustomProperty_GameTitle:
return mDriver.GetDsp()->GetGameTitle();
case kAudioUnitCustomProperty_SongTitle:
return mDriver.GetDsp()->GetSongTitle();
case kAudioUnitCustomProperty_NameOfDumper:
return mDriver.GetDsp()->GetNameOfDumper();
case kAudioUnitCustomProperty_ArtistOfSong:
return mDriver.GetDsp()->GetArtistOfSong();
case kAudioUnitCustomProperty_SongComments:
return mDriver.GetDsp()->GetSongComments();
default:
break;
}
return 0;
}
//-----------------------------------------------------------------------------
bool C700Kernel::GetPropertyStructValue( int inID, void *outData )
{
return false;
}
//-----------------------------------------------------------------------------
bool C700Kernel::SetPropertyValue( int inID, float value )
{
bool boolData = value>0.5f?true:false;
if (mPropertyParams[inID].saveToGlobal) {
mGlobalSettingsHasChanged = true;
}
switch (inID) {
case kAudioUnitCustomProperty_BaseKey:
mVPset[mEditProg].basekey = value;
mDriver.RefreshKeyMap();
return true;
case kAudioUnitCustomProperty_LowKey:
mVPset[mEditProg].lowkey = value;
mDriver.RefreshKeyMap();
return true;
case kAudioUnitCustomProperty_HighKey:
mVPset[mEditProg].highkey = value;
mDriver.RefreshKeyMap();
return true;
case kAudioUnitCustomProperty_LoopPoint:
mVPset[mEditProg].lp = value;
/*
if (mVPset[mEditProg].lp > mVPset[mEditProg].brrSize()) {
mVPset[mEditProg].lp = mVPset[mEditProg].brrSize();
}*/
if ( mVPset[mEditProg].lp < 0 ) {
mVPset[mEditProg].lp = 0;
}
mDriver.UpdateLoopPoint(mEditProg);
return true;
case kAudioUnitCustomProperty_Loop:
mVPset[mEditProg].loop = boolData;
if (boolData) {
mVPset[mEditProg].setLoop();
}
else {
mVPset[mEditProg].unsetLoop();
}
mDriver.UpdateLoopFlag(mEditProg);
return true;
case kAudioUnitCustomProperty_Echo:
mVPset[mEditProg].echo = boolData;
return true;
case kAudioUnitCustomProperty_Bank:
mVPset[mEditProg].bank = value;
mDriver.RefreshKeyMap();
return true;
case kAudioUnitCustomProperty_AR:
mVPset[mEditProg].ar = value;
return true;
case kAudioUnitCustomProperty_DR:
mVPset[mEditProg].dr = value;
return true;
case kAudioUnitCustomProperty_SL:
mVPset[mEditProg].sl = value;
return true;
case kAudioUnitCustomProperty_SR1:
mVPset[mEditProg].sr1 = value;
return true;
case kAudioUnitCustomProperty_SR2:
mVPset[mEditProg].sr2 = value;
return true;
case kAudioUnitCustomProperty_VolL:
mVPset[mEditProg].volL = value;
return true;
case kAudioUnitCustomProperty_VolR:
mVPset[mEditProg].volR = value;
return true;
case kAudioUnitCustomProperty_EditingProgram:
{
mEditProg = value;
if (mEditProg>127) mEditProg=127;
if (mEditProg<0) mEditProg=0;
// 選択チャンネルのプログラムをチェンジ
if ( parameterSetFunc ) {
if ( mEditChannel == 0 ) {
parameterSetFunc(kParam_program, mEditProg, paramSetUserData );
}
else {
parameterSetFunc(kParam_program_2 + mEditChannel - 1, mEditProg, paramSetUserData );
}
}
// 表示更新が必要なプロパティの変更を通知する
if ( propertyNotifyFunc ) {
auto it = mPropertyParams.begin();
while (it != mPropertyParams.end()) {
if (it->second.saveToProg || it->first == kAudioUnitCustomProperty_Loop) {
propertyNotifyFunc(it->first, propNotifyUserData);
}
it++;
}
}
return true;
}
case kAudioUnitCustomProperty_EditingChannel:
{
mEditChannel = value;
if (mEditChannel>15) mEditChannel=15;
if (mEditChannel<0) mEditChannel=0;
// 変更したチャンネルのプログラムチェンジを取得してmEditProgに設定する
if ( parameterSetFunc ) {
if ( mEditChannel == 0 ) {
mEditProg = GetParameter(kParam_program);
}
else {
mEditProg = GetParameter(kParam_program_2 + mEditChannel - 1);
}
}
// 表示更新が必要なプロパティの変更を通知する
if ( propertyNotifyFunc ) {
auto it = mPropertyParams.begin();
while (it != mPropertyParams.end()) {
if (it->second.saveToProg || it->first == kAudioUnitCustomProperty_Loop) {
propertyNotifyFunc(it->first, propNotifyUserData);
}
it++;
}
propertyNotifyFunc(kAudioUnitCustomProperty_EditingProgram, propNotifyUserData);
}
return true;
}
//エコー
case kAudioUnitCustomProperty_Band1:
case kAudioUnitCustomProperty_Band2:
case kAudioUnitCustomProperty_Band3:
case kAudioUnitCustomProperty_Band4:
case kAudioUnitCustomProperty_Band5:
{
int filter[8];
mFilterBand[inID-kAudioUnitCustomProperty_Band1] = value;
if (!mInRestoreParameters) {
CalcFIRParam(mFilterBand, filter);
if ( parameterSetFunc ) {
for ( int i=0; i<8; i++ ) {
parameterSetFunc(kParam_fir0+i, filter[i], paramSetUserData);
}
}
}
return true;
}
case kAudioUnitCustomProperty_NoteOnTrack_1:
case kAudioUnitCustomProperty_NoteOnTrack_2:
case kAudioUnitCustomProperty_NoteOnTrack_3:
case kAudioUnitCustomProperty_NoteOnTrack_4:
case kAudioUnitCustomProperty_NoteOnTrack_5:
case kAudioUnitCustomProperty_NoteOnTrack_6:
case kAudioUnitCustomProperty_NoteOnTrack_7:
case kAudioUnitCustomProperty_NoteOnTrack_8:
case kAudioUnitCustomProperty_NoteOnTrack_9:
case kAudioUnitCustomProperty_NoteOnTrack_10:
case kAudioUnitCustomProperty_NoteOnTrack_11:
case kAudioUnitCustomProperty_NoteOnTrack_12:
case kAudioUnitCustomProperty_NoteOnTrack_13:
case kAudioUnitCustomProperty_NoteOnTrack_14:
case kAudioUnitCustomProperty_NoteOnTrack_15:
case kAudioUnitCustomProperty_NoteOnTrack_16:
return true;
case kAudioUnitCustomProperty_MaxNoteTrack_1:
case kAudioUnitCustomProperty_MaxNoteTrack_2:
case kAudioUnitCustomProperty_MaxNoteTrack_3:
case kAudioUnitCustomProperty_MaxNoteTrack_4:
case kAudioUnitCustomProperty_MaxNoteTrack_5:
case kAudioUnitCustomProperty_MaxNoteTrack_6:
case kAudioUnitCustomProperty_MaxNoteTrack_7:
case kAudioUnitCustomProperty_MaxNoteTrack_8:
case kAudioUnitCustomProperty_MaxNoteTrack_9:
case kAudioUnitCustomProperty_MaxNoteTrack_10:
case kAudioUnitCustomProperty_MaxNoteTrack_11:
case kAudioUnitCustomProperty_MaxNoteTrack_12:
case kAudioUnitCustomProperty_MaxNoteTrack_13:
case kAudioUnitCustomProperty_MaxNoteTrack_14:
case kAudioUnitCustomProperty_MaxNoteTrack_15:
case kAudioUnitCustomProperty_MaxNoteTrack_16:
mMaxNote[inID-kAudioUnitCustomProperty_MaxNoteTrack_1] = value;
mOnNotes[inID-kAudioUnitCustomProperty_NoteOnTrack_1] = 0;
return true;
case kAudioUnitCustomProperty_IsEmaphasized:
mVPset[mEditProg].isEmphasized = boolData;
return true;
case kAudioUnitCustomProperty_SustainMode:
mVPset[mEditProg].sustainMode = boolData;
return true;
case kAudioUnitCustomProperty_MonoMode:
mVPset[mEditProg].monoMode = boolData;
return true;
case kAudioUnitCustomProperty_PortamentoOn:
mVPset[mEditProg].portamentoOn = boolData;
return true;
case kAudioUnitCustomProperty_PitchModulationOn:
mVPset[mEditProg].pmOn = boolData;
return true;
case kAudioUnitCustomProperty_NoiseOn:
mVPset[mEditProg].noiseOn = boolData;
return true;
case kAudioUnitCustomProperty_PortamentoRate:
mVPset[mEditProg].portamentoRate = value;
mDriver.UpdatePortamentoTime(mEditProg);
return true;
case kAudioUnitCustomProperty_NoteOnPriority:
mVPset[mEditProg].noteOnPriority = value;
mDriver.AllNotesOff();
return true;
case kAudioUnitCustomProperty_ReleasePriority:
mVPset[mEditProg].releasePriority = value;
mDriver.AllNotesOff();
return true;
case kAudioUnitCustomProperty_IsHwConnected:
return true;
case kAudioUnitCustomProperty_RecSaveAsSpc:
mDriver.GetDsp()->SetRecSaveAsSpc(value==0 ? false:true);
return true;
case kAudioUnitCustomProperty_RecSaveAsSmc:
mDriver.GetDsp()->SetRecSaveAsSmc(value==0 ? false:true);
return true;
case kAudioUnitCustomProperty_TimeBaseForSmc:
{
if (value == 0) {
mDriver.GetDsp()->SetTimeBaseForSmc(C700DSP::SmcTimeBaseNTSC);
}
else {
mDriver.GetDsp()->SetTimeBaseForSmc(C700DSP::SmcTimeBasePAL);
}
return true;
}
case kAudioUnitCustomProperty_RepeatNumForSpc:
mDriver.GetDsp()->SetRepeatNumForSpc(value);
return true;
case kAudioUnitCustomProperty_FadeMsTimeForSpc:
mDriver.GetDsp()->SetFadeMsTimeForSpc(value);
return true;
case kAudioUnitCustomProperty_MaxNoteOnTotal:
mTotalOnNotes = value;
return true;
default:
return false;
}
}
//-----------------------------------------------------------------------------
bool C700Kernel::SetPropertyDoubleValue( int inID, double value )
{
if (mPropertyParams[inID].saveToGlobal) {
mGlobalSettingsHasChanged = true;
}
switch (inID) {
case kAudioUnitCustomProperty_Rate:
mVPset[mEditProg].rate = value;
return true;
case kAudioUnitCustomProperty_RecordStartBeatPos:
mRecordStartBeatPos = value;
return true;
case kAudioUnitCustomProperty_RecordLoopStartBeatPos:
mRecordLoopStartBeatPos = value;
return true;
case kAudioUnitCustomProperty_RecordEndBeatPos:
mRecordEndBeatPos = value;
return true;
default:
return false;
}
}
bool C700Kernel::SetPropertyPtrValue( int inID, const void *inPtr, int size )
{
if (mPropertyParams[inID].saveToGlobal) {
mGlobalSettingsHasChanged = true;
}
switch (inID) {
#if AU
case kAudioUnitCustomProperty_PGDictionary:
{
CFDictionaryRef pgdata = reinterpret_cast<CFDictionaryRef>(inPtr);
int editProg = GetPropertyValue(kAudioUnitCustomProperty_EditingProgram);
RestorePGDataDic(pgdata, editProg);
return true;
}
#endif
case kAudioUnitCustomProperty_BRRData:
{
SetBRRData(reinterpret_cast<const unsigned char *>(inPtr), size);
return true;
}
case kAudioUnitCustomProperty_SongPlayerCode:
{
PlayerCodeReader *code = new PlayerCodeReader(inPtr, size, true);
if (!code->IsLoaded()) {
delete code;
return true;
}
if (mCodeFile != NULL) {
delete mCodeFile;
}
mCodeFile = code;
mDriver.GetDsp()->SetSpcPlayerCode(mCodeFile->getSpcPlayerCode(), mCodeFile->getSpcPlayerCodeSize());
mDriver.GetDsp()->SetSmcEmulationVector(mCodeFile->getSmcEmulationVector());
mDriver.GetDsp()->SetSmcNativeVector(mCodeFile->getSmcNativeVector());
mDriver.GetDsp()->SetSmcPlayerCode(mCodeFile->getSmcPlayerCode(), mCodeFile->getSmcPlayerCodeSize());
mDriver.GetDsp()->SetSongPlayCodeVer(mCodeFile->getVersion());
return true;
}
case kAudioUnitCustomProperty_SourceFileRef:
{
SetSourceFilePath(reinterpret_cast<const char *>(inPtr));
return true;
}
case kAudioUnitCustomProperty_ProgramName:
{
SetProgramName(reinterpret_cast<const char *>(inPtr));
return true;
}
case kAudioUnitCustomProperty_SongRecordPath:
{
mDriver.GetDsp()->SetSongRecordPath(reinterpret_cast<const char *>(inPtr));
return true;
}
case kAudioUnitCustomProperty_GameTitle:
{
mDriver.GetDsp()->SetGameTitle(reinterpret_cast<const char *>(inPtr));
return true;
}
case kAudioUnitCustomProperty_SongTitle:
{
mDriver.GetDsp()->SetSongTitle(reinterpret_cast<const char *>(inPtr));
return true;
}
case kAudioUnitCustomProperty_NameOfDumper:
{
mDriver.GetDsp()->SetNameOfDumper(reinterpret_cast<const char *>(inPtr));
return true;