Skip to content

Commit a8435b5

Browse files
committed
- 6.0.3.0 Support Loop Point PAULA_8364(AMIGA).
- Limitation1: The length of the PCM must be at least 2 bytes. - Limitation2: Does not support too short/too early loop point.
1 parent 681b787 commit a8435b5

File tree

5 files changed

+65
-33
lines changed

5 files changed

+65
-33
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
MAmidiMEmo 6.0.2.3 Itoken (c)2019, 2025 / GPL-2.0
1+
MAmidiMEmo 6.0.3.0 Itoken (c)2019, 2025 / GPL-2.0
22

33
*** What is the MAmidiMEmo? ***
44

@@ -274,6 +274,9 @@ e.g.) YM2151 has 8ch FM sounds, so you can play 8 chords on MIDI 1ch or sharing
274274
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=SNQ9JE3JAQMNQ)
275275

276276
*** Changes
277+
- 6.0.3.0 Support Loop Point PAULA_8364(AMIGA).
278+
- Limitation1: The length of the PCM must be at least 2 bytes.
279+
- Limitation2: Does not support too short/too early loop point.
277280
- 6.0.2.3 Fixed PAULA_8364(AMIGA) Wait I/O error.
278281
- 6.0.2.2 Fixed PAULA_8364(AMIGA) annoying noize issue.
279282
- 6.0.2.1 Fixed PAULA_8364(AMIGA) freezing issue.

src/VSIF/VSIF_AMIGA/main.c

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -467,10 +467,12 @@ VWritef("Completed serial setting.\n", NULL);
467467

468468
UBYTE id = *dataBufPtr++;
469469
UWORD len = *(UWORD *)dataBufPtr++;
470-
//UWORD loop = *(UWORD *)dataBufPtr++;
470+
//UWORD loop = *(UWORD *)dataBufPtr;
471471
//if(loop >= len)
472472
// loop = 0xFFFF;
473-
UWORD loop = 0;
473+
#ifndef NO_LOOP
474+
UWORD loop = 0;
475+
#endif
474476
#ifdef LOG
475477
ULONG arg[] = {id, len, loop};
476478
VWritef("%N %N %N\n", arg);
@@ -483,48 +485,48 @@ VWritef("Completed serial setting.\n", NULL);
483485
BYTE* pcmDataPtr = (BYTE*)AllocMem(len, MEMF_CHIP);
484486
if(pcmDataPtr != NULL)
485487
{
486-
UBYTE *pcmptr = (UBYTE *)readArray(pcmDataPtr, len);
487-
if(pcmptr == NULL)
488+
if(readArray(pcmDataPtr, len) == NULL)
488489
{
489-
error = -1;
490+
error = -1;
490491
FreeMem(pcmDataPtr, len);
491492
break;
492-
}
493+
}
494+
requestSerial(5);
493495
}else
494496
{
495497
UWORD received = 0;
496498
UWORD chunk_size;
497-
while (received < len) {
499+
while (received < len)
500+
{
498501
// 256バイト単位で受信(最後のブロックは余りを処理)
499502
chunk_size = (len - received >= SERIAL_BUFFER_SIZE) ? SERIAL_BUFFER_SIZE : (len - received);
500503
readArray(recvBuffer[recvBufferId], chunk_size);
501504
received += chunk_size;
502-
}
505+
}
506+
requestSerial(5);
503507
showMessage("No PCM memory!");
504-
error = -1;
505508
break;
506509
}
507510

508511
pdt->dataPtr = pcmDataPtr;
509512
pdt->length = len;
510-
pdt->loop = loop;
513+
pdt->loop = 0;
511514
}else{
515+
requestSerial(5);
516+
512517
pdt->dataPtr = NULL;
513518
pdt->length = 0;
514519
pdt->loop = 0;
515520
}
516-
requestSerial(5);
517-
518521
if(oldPcm != NULL)
519522
FreeMem(oldPcm, oldLen);
520-
521523
#ifdef LOG
522524
VWritef("PCM Received\n", NULL);
523525
#endif
524526
}
525527
break;
526-
case 7: // PCM Loop
527-
{
528+
case 7: // Change PCM Loop Pos
529+
{
528530
requestSerial(5);
529531

530532
UBYTE id = *dataBufPtr++;
@@ -539,6 +541,23 @@ VWritef("Completed serial setting.\n", NULL);
539541
#endif
540542
}
541543
break;
544+
545+
case 8: // Set PCM Loop
546+
{
547+
requestSerial(5);
548+
549+
UBYTE id = *dataBufPtr++;
550+
UWORD loop = *(UWORD *)dataBufPtr++;
551+
552+
custom->aud[ch].ac_len = (pcmDataTable[id].length - loop) >> 1;
553+
custom->aud[ch].ac_ptr = (volatile UWORD *)(pcmDataTable[id].dataPtr + loop);
554+
#ifdef LOG
555+
ULONG arg[] = {id, loop};
556+
VWritef("LOOP %N %N\n", arg);
557+
#endif
558+
}
559+
break;
560+
542561
default:
543562
error = -1;
544563
break;
56 Bytes
Binary file not shown.

src/mamidimemo/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public static class Program
4141
/// <summary>
4242
///
4343
/// </summary>
44-
public const string FILE_VERSION = "6.0.2.3";
44+
public const string FILE_VERSION = "6.0.3.0";
4545

4646
public const string FILE_COPYRIGHT = @"Virtual chiptune sound MIDI module ""MAmidiMEmo"" Version {0}
4747
Copyright(C) 2019, 2025 Itoken.All rights reserved.";

src/mamidimemo/instruments/Chips/PAULA_8364.cs

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ private void transferPcmData(PaulaTimbre tim, FormProgress fp)
439439
// id, len, loop, data...
440440
List<byte> data = new List<byte>
441441
{
442-
(byte)PAULA_CMD.PCM,
442+
(byte)PAULA_CMD.SetPcmData,
443443
//ID
444444
(byte)tim.Index,
445445
//Length
@@ -496,7 +496,7 @@ private void transferPcmData(PaulaTimbre tim, FormProgress fp)
496496
fp.Percentage = 100;
497497
Application.DoEvents();
498498
#if USE_PCM_LOOP
499-
Paula8364Write(UnitNumber, PAULA_CMD.PCM_LOOP, (uint)tim.Index, (ushort)(tim.LoopEnable ? tim.LoopPoint : 0xFFFF), true);
499+
Paula8364Write(UnitNumber, PAULA_CMD.SetPcmDataLoop, (uint)tim.Index, (ushort)(tim.LoopEnable ? tim.LoopPoint : 0xFFFF), true);
500500
#endif
501501
}
502502
break;
@@ -591,7 +591,7 @@ private void Paula8364Write(uint unitNumber, PAULA_CMD type, uint address, ushor
591591
}
592592
}
593593
break;
594-
case PAULA_CMD.PCM_LOOP:
594+
case PAULA_CMD.SetPcmDataLoop:
595595
lock (sndEnginePtrLock)
596596
{
597597
switch (CurrentSoundEngine)
@@ -644,16 +644,18 @@ private void Paula8364Keyon(uint unitNumber, byte ch, byte id, byte vol, ushort
644644
ch = chConvert[ch];
645645
if (loop >= length)
646646
loop = 0xffff;
647-
#if !USE_PCM_LOOP
648-
loop = 0;
649-
#endif
647+
//#if !USE_PCM_LOOP
648+
// loop = 0;
649+
//#endif
650650

651651
lock (sndEnginePtrLock)
652652
{
653653
switch (CurrentSoundEngine)
654654
{
655655
case SoundEngineType.VSIF_AMIGA:
656656
vsifClient.RawWriteData(new byte[] { (byte)((byte)PAULA_CMD.KeyOn | ch << 4), id, vol, (byte)(period >> 8), (byte)period }, null);
657+
if(loop > 0)
658+
vsifClient.RawWriteData(new byte[] { (byte)((byte)PAULA_CMD.SetLoop | ch << 4), id, (byte)(loop >> 8), (byte)loop, 0 }, null);
657659
break;
658660
}
659661
}
@@ -1170,7 +1172,11 @@ public override void KeyOn()
11701172
if (freq > 0xffff)
11711173
freq = 0xffff;
11721174

1173-
ushort loop = loopEn ? loopPoint : (ushort)0xffff;
1175+
//ushort loop = loopEn ? loopPoint : (ushort)0xffff;
1176+
ushort pcmLen = (ushort)timbre.PcmData.Length;
1177+
if(pcmLen < 2)
1178+
pcmLen = 2;
1179+
ushort loop = loopEn ? loopPoint : (ushort)(pcmLen - 2);
11741180
parentModule.Paula8364Keyon(parentModule.UnitNumber,
11751181
(byte)Slot, timbreIndex, (byte)vol, (ushort)freq, (ushort)timbre.PcmData.Length, loop);
11761182
}
@@ -1275,11 +1281,12 @@ public uint SampleRate
12751281

12761282
[DataMember]
12771283
[Category("Sound")]
1278-
[Description("Loop point enable")]
1284+
[Description("Loop point enabled\r\n"+
1285+
"LIMITATION: Does not support too short/too early loop point.")]
12791286
[EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))]
12801287
[DefaultValue(false)]
12811288
#if !USE_PCM_LOOP
1282-
[Browsable(false)]
1289+
// [Browsable(false)]
12831290
#endif
12841291
public bool LoopEnable
12851292
{
@@ -1295,7 +1302,7 @@ public bool LoopEnable
12951302
if (Instrument != null)
12961303
{
12971304
((PAULA_8364)Instrument).
1298-
Paula8364Write(Instrument.UnitNumber, PAULA_CMD.PCM_LOOP, (uint)Index, (ushort)(f_LoopEnable ? f_LoopPoint : 0xFFFF), true);
1305+
Paula8364Write(Instrument.UnitNumber, PAULA_CMD.SetPcmDataLoop, (uint)Index, (ushort)(f_LoopEnable ? f_LoopPoint : 0xFFFF), true);
12991306
}
13001307
}
13011308
}
@@ -1305,12 +1312,13 @@ public bool LoopEnable
13051312

13061313
[DataMember]
13071314
[Category("Sound")]
1308-
[Description("Set loop point (0 - 65534) (65535 is loop off)")]
1315+
[Description("Set loop point (0 - 65534) (65535 is loop off)\r\n"+
1316+
"LIMITATION: Does not support too short/too early loop point.")]
13091317
[DefaultValue(typeof(ushort), "0")]
13101318
[SlideParametersAttribute(0, 65534)]
13111319
[EditorAttribute(typeof(SlideEditor), typeof(System.Drawing.Design.UITypeEditor))]
13121320
#if !USE_PCM_LOOP
1313-
[Browsable(false)]
1321+
// [Browsable(false)]
13141322
#endif
13151323
public ushort LoopPoint
13161324
{
@@ -1326,7 +1334,7 @@ public ushort LoopPoint
13261334
if (Instrument != null)
13271335
{
13281336
((PAULA_8364)Instrument).
1329-
Paula8364Write(Instrument.UnitNumber, PAULA_CMD.PCM_LOOP, (uint)Index, (ushort)(f_LoopEnable ? f_LoopPoint : 0xFFFF), true);
1337+
Paula8364Write(Instrument.UnitNumber, PAULA_CMD.SetPcmDataLoop, (uint)Index, (ushort)(f_LoopEnable ? f_LoopPoint : 0xFFFF), true);
13301338
}
13311339
}
13321340
}
@@ -1339,7 +1347,8 @@ public ushort LoopPoint
13391347
[DataMember]
13401348
[Category("Sound")]
13411349
[Description("Signed 8bit PCM Raw Data or WAV Data. (MAX 64K samples, 1ch)\r\n" +
1342-
"Need to increase the Gain value to sound 8bit PCM data.")]
1350+
"Need to increase the Gain value to sound 8bit PCM data.\r\n"+
1351+
"LIMITATION: The length of the PCM must be at least 2 bytes.")]
13431352
[PcmFileLoaderEditor("Audio File(*.raw, *.wav)|*.raw;*.wav", 0, 8, 1, 65535)]
13441353
public sbyte[] PcmData
13451354
{
@@ -1908,8 +1917,9 @@ public enum PAULA_CMD
19081917
KeyOn = 3,
19091918
KeyOff = 4,
19101919
Filter = 5,
1911-
PCM = 6,
1912-
PCM_LOOP = 7,
1920+
SetPcmData = 6,
1921+
SetPcmDataLoop = 7,
1922+
SetLoop = 8,
19131923
}
19141924

19151925

0 commit comments

Comments
 (0)