Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Not playing back the entire audio file #7

Closed
adlez27 opened this issue Apr 2, 2021 · 2 comments
Closed

Not playing back the entire audio file #7

adlez27 opened this issue Apr 2, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@adlez27
Copy link
Owner

adlez27 commented Apr 2, 2021

This only seems to happen with lines recorded in Akorin, and not to other audio that's been loaded in. Needs more investigation

@adlez27 adlez27 added bug Something isn't working question Further information is requested labels Apr 2, 2021
@adlez27
Copy link
Owner Author

adlez27 commented Apr 3, 2021

This bit might be suspect

public void Read ()
        {
            if (File.Exists(FullName) && !recorded)
            {
                byte[] rawBytes = File.ReadAllBytes(FullName);
                data = new ArraySegment<byte>(rawBytes, 46, rawBytes.Length - 46).ToList();
                stream = Bass.CreateStream(rawBytes, 0, rawBytes.Length, BassFlags.Mono);
            }
            else if (recorded)
            {
                byte[] reRead;
                var format = new WaveFormat(44100, 16, 1);
                using (MemoryStream ms = new MemoryStream())
                using (WaveFileWriter wfw = new WaveFileWriter(ms, format))
                {
                    wfw.Write(Data, Data.Length);
                    reRead = ms.GetBuffer();
                }
                stream = Bass.CreateStream(reRead, 0, reRead.Length, BassFlags.Mono);
            }
        }

Maybe prefer to read from file over rereading from data when something was just recorded. Rereading seems to cut the audio off halfway- could be the Mono flag?

@adlez27
Copy link
Owner Author

adlez27 commented Apr 3, 2021

Just needed to write for twice the length of Data with the WaveFileWriter lol

@adlez27 adlez27 closed this as completed Apr 3, 2021
@adlez27 adlez27 removed the question Further information is requested label Apr 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant