My Music Editor

Started by Hardcoal, May 24, 2021, 23:57:24

Previous topic - Next topic

Midimaster

Quote...maybe something is wrong with the save function...
Yes, someting is wrong

Because you always define the TAudioSample 4times too big, it looks like the defining of the CreateStaticBank() would be correct:
wrong:
Method SaveSample(MySample:MySample_Type, SampleFilename:String = "")
....
'Create a bank from the Samples
SndBank = CreateStaticBank(MySample.Sample.samples, MySample.Sample.length)
...
'Write wav sound data
SndBank.Write(FileStream, 0, MySample.Sample.length)



correct:
Code (BlitzMax) Select
Method SaveSample(MySample:MySample_Type, SampleFilename:String = "")
....
BlockAlign = CHANNELS * BITRATE /8
....
'Create a bank from the Samples
SndBank = CreateStaticBank(MySample.Sample.samples, MySample.Sample.length*BlockAlign)
...
'Write wav sound data
SndBank.Write(FileStream, 0, MySample.Sample.length*BlockAlign)
...back from Egypt

iWasAdam

@Midimaster
Now if I recall...  ;D
wasn't it mentioned that banks were not the best way to store things?

MySample.Sample.samples, MySample.Sample.length

surely it would have been much simpler for you to program the interface to be:
MySample.samples, MySample.length

and of the sake of clarity:
BlockAlign = CHANNELS * BITRATE /8
        ....
        'Create a bank from the Samples
        SndBank = CreateStaticBank(MySample.Sample.samples, MySample.Sample.length*BlockAlign)


BlockAlign is something you have conjoured up to fix the save issue you created.

SndBank = CreateStaticBank(MySample.Sample.samples, MySample.Sample.length)
is a very logical was to think about the data and deal with it...

But of course I know absolutely NOTHING about audio and am talking out of my bottom...
;D

Midimaster

#77
Quote from: iWasAdam on July 18, 2021, 11:26:06
@Midimaster
Now if I recall...  ;D
wasn't it mentioned that banks were not the best way to store things?

No! It wasn't mentioned! not by me, not by anybody else! And again: I did not write this code! Why asking me?
btw... the Banking thing is one of the thing which is working in his code!

Quotesurely it would have been much simpler for you to program the interface to be:
Code:
MySample.samples, MySample.length

Again, dear IWasAdam. I cases of SF_STEREO16LE and SF_MONO16LE the 1.50 BlitzMax function Samples.Length() does NOT report the size of the TAudioSample in Bytes! Call it a feature, I would call it a bug! And also a 2sec CreateAudioSample() does not allocate 88.200 Byte when you write ...
CreateAudioSample(44100*2, 44100, SF_STEREO16LE
...., but 352.800 !!!
And this...
CreateAudioSample(88200, 44100, SF_MONO16LE
not 88000, but 176.400 !!!

So you cannot use Sample.Length()  to calculate the saving size, but it needs to be
 
SizeInBytes = Sample.Length()*CHANNELS*BITRATE /8


If you of course define a 2sec. SampleBuffer wrongly to big:
CreateAudioSample (44100*8, 44100, SF_STEREO16LE
...you can now use Sample.Length (352.000) to save the Audio. Because the wrongly calculated Sample.Length is now exactly the same result a correct defined Sample.Length()*CHANNELS*BITRATE /8 would deliver too.
Only dis-advantage in this calculation: The TAudioSample will mysteriously play longer than 2 seconds: exactly 8 seconds.

QuoteBut of course I know absolutely NOTHING about audio and am talking out of my bottom...
I don't know which part of your body you use to produce thinking and talking... but it is "not the best" writing style coming out!

...back from Egypt

Hardcoal

This is a quick response, Ill detail later..

Perhaps you missed what I've said..
Everything is working Perfect!

I mean Everything!

My method worked along with all your advices dear people.

Ill optimize the resolution of displaying the Sample later.. now that it works it should be easy..
Before I play a Sample I divide the length by 4
and the restore it back by multiplying by 4

For some reason that works, and the ChannelPlaying reports exactly when the sample ends..


Code

iWasAdam

QuoteI don't know which part of your body you use to produce thinking and talking... but it is "not the best" writing style coming out!
It's the part that rewrote the entire blitzMax audio code to support full audio synthesis in c++ with no help and no complaints.
It's the part that wrote the entire audio sub system to support up to 2048 simultaneous voices with no latency and no playback slowdown
It's the part that created filters, lfo and envelope system with a cross matrix on individual voices
It's the part that created the entire UI, sequencer, timing systems, programmable effects core, 3d audio display...

And it's the part that knows NOTHING about what I am talking about - think on that

Qube

Quote from: iWasAdam on July 18, 2021, 15:16:57
It's the part that...

It's the part that wrote QasarBeach ( iWasAdam not me as I'm dumb like that )
Mac Studio M1 Max ( 10 core CPU - 24 core GPU ), 32GB LPDDR5, 512GB SSD,
Beelink SER7 Mini Gaming PC, Ryzen 7 7840HS 8-Core 16-Thread 5.1GHz Processor, 32G DDR5 RAM 1T PCIe 4.0 SSD
MSI MEG 342C 34" QD-OLED Monitor

Until the next time.

Hardcoal

#81
I think this site is gone forever.. But its not :)
I was willing to pay for it to remain..

Anyway.. back to business.
Im working now on Moving the cursor.. and playing the samples from the middle and so on

Guys please forgive me if I dont replay to all the posts you posted..
Its too much of an overload for me.
I prefer to spend time going forward when things are working..

So, for now Ill move on. But I will reread everything Later
I would be glad to clean all this post because it was one big mess, but thats not in my hands.

I want to know if its possible to Make sound Effects in Real time Like Echo..
and so on..

Question: Why in the SaveSample Function you have this 40 Addings? FileStream.WriteInt(MySample.Sample.length + 40)


Code

Steve Elliott

#82
It's very disappointing when new people come to a site and immediately start making assumptions about people, start making demands.

They've been here 5 minutes and so should try and understand some people leave because, well they have 'issues' and could have an argument in an empty room, rather than guessing why they left, and so tarnishing the good peeps here.

The arrogance here is off the scale.  We have been here sometime and know Adam's credentials in the sound arena and coding prowess.
Win11 64Gb 12th Gen Intel i9 12900K 3.2Ghz Nvidia RTX 3070Ti 8Gb
Win11 16Gb 12th Gen Intel i5 12450H 2Ghz Nvidia RTX 2050 8Gb
Win11  Pro 8Gb Celeron Intel UHD Graphics 600
Win10/Linux Mint 16Gb 4th Gen Intel i5 4570 3.2GHz, Nvidia GeForce GTX 1050 2Gb
macOS 32Gb Apple M2Max
pi5 8Gb
Spectrum Next 2Mb

Hardcoal

Steve Elliott
I totally Agree with you..
and to criticize someone of the scale of IWasAdam is even more ridicules

I expect from such a site of this level to display really polite behavior towards one other..

I totally love and value the people here..
everything that Is done here comes from pure will to help, one other.


Code

Hardcoal

#84
Ok Im back after some break..  (I did some other programming missions)

Hope no one is Mad over me from whatever reason..

Anyway I did PlaySampleFromMIddle function and here it is..
Please tell me if i did it right

Method PlaySampleSection(MySample:MySample_Type, StartPointInSecs:Float = 0, LengthInSecs:Float = 0)
Local LengthInBytes, StartPointInBytes

If LengthInSecs <= 0 Then Return

LengthInBytes = LengthInSecs * SAMPLE_RATE * 4
StartPointInBytes = StartPointInSecs * SAMPLE_RATE * 4  'should be short

Local TempSample:TAudioSample = CreateAudioSample(LengthInBytes, mysample.Sample.hertz, mysample.Sample.format)
Local Counter
For Local I = StartPointInBytes To StartPointInBytes + LengthInBytes
TempSample.samples[Counter] = MySample.Sample.samples[I]
Counter = Counter + 1
Next

Local TS:TSound = LoadSound(TempSample)
PlaySound(TS)
End Method



I added a Demo For what I reached so far..
This Crap is Rather confusing I must Admit

https://drive.google.com/file/d/1jCpl70KQ9FNX3mn4olT4ePTHQJAbv5EL/view?usp=sharing
Code

iWasAdam

@Hardcoal
My advice is to take things at your own pace with audio - it's very low level stuff, pointers and bytes and all sorts of weird little things that make something work one day and then not work the next.

What you have done (so far) deserves respect - particularly as you are getting conflicting and sometimes unusual advice as to what to do and what to not do.

You also deserve kudos for sticking with your editor concepts, making them work and getting results - all of this is tedius and most people give up - so you are doing things right for you \o/


I know that I can come across 'snarky' at times. but time has taught me some of the 'tricks' that make programming simpler.

Some things are easy (showing a waveform)
Some things are more difficult (having variable loop points in a sample) (showing the current play position in a sample)
Some things can be really hard (realtime filters, lfos and envelopes)

but don't be put off there are ways around everything ;)

Hardcoal

#86
Thanks Adam very kind words
All Im doing including my game editor I never gave up on anything..
I use stuff I made from all the projects and also always planning to continue everything I started..
I building projects In a way that it is easy to Drop them and return to them rather quickly and understand what's going on their.

About this music Editor.. I do Hold Great respect to anyone who put of from his time to help me..
So ill never complain and mention anyone who helped me in Credits And If I made money out of something Ill also wont forget people who helped me.
Im doing things on my own pace and mental state.
Ye Im pleased with my achievements and midi master especially helped me so much, I owe him a lot.

(My mood does not always allow me to be stable at one thing)

What Im doing is Tools..
Tools that I can later Clone from one place to another ..
And see what I can make of it.

I planning on small projects , not like before when I tried to take over the world..

Like an Audio Recorder..
and those sort of things.

Im continuing on this sample editing manipulation up to a point.
than ill drop it and move on to other thing

Hope ill keep getting help here.
cause its for the benefit of all




Code

Hardcoal

What is the best way to Free a TaudioSample..?
And Reconstruct it

Cheers
Code

iWasAdam

I'm not at my machine to check things. But usually (if it's a ng class) you just set it to null

Class = null

This will set the internal garbage collector to automatically free thing for you. Derron can probably give you the exact details...

iWasAdam

No problem.

The TSample (PlaySampleFromMIddle function) - without running it looks generally right.

my general process is similar:
1. create new sample of the size you need
2. copy, modify (etc) from the old sample to the new sample

:)