public void FromVegas(Vegas vegas) { myVegas = vegas; Timecode fourF = Timecode.FromMilliseconds(133); Timecode sixF = Timecode.FromMilliseconds(200); foreach (Track track in myVegas.Project.Tracks) { if (track.IsVideo()) { foreach (TrackEvent evnt in track.Events) { if (evnt.Selected) { VideoEvent videoEvent = (VideoEvent)evnt; Envelope VelEnv = new Envelope(EnvelopeType.Velocity); videoEvent.Envelopes.Add(VelEnv); Timecode t = evnt.Start - evnt.Start; EnvelopePoint a = VelEnv.Points.GetPointAtX(t); if (a != null) { a.Y = 1.5; } ; EnvelopePoint bTest = VelEnv.Points.GetPointAtX(fourF); if (bTest == null) { EnvelopePoint b = new EnvelopePoint(fourF, 0.50); VelEnv.Points.Add(b); } ; a.Curve = CurveType.Fast; EnvelopePoint cTest = VelEnv.Points.GetPointAtX(evnt.Length - sixF); if (cTest == null) { EnvelopePoint c = new EnvelopePoint(evnt.Length - fourF, 0.50); VelEnv.Points.Add(c); c.Curve = CurveType.Slow; } ; EnvelopePoint dTest = VelEnv.Points.GetPointAtX(evnt.Length); if (dTest == null) { EnvelopePoint d = new EnvelopePoint(evnt.Length, 10); VelEnv.Points.Add(d); } ; } } } } }
void ExportEnvelopePoint(XmlElement parent, EnvelopePoint point) { XmlElement elt = AddChild(parent, "Point"); elt.SetAttribute("X", TimecodeToString(point.X)); elt.SetAttribute("Nanos", point.X.Nanos.ToString(myNumberFormat)); elt.SetAttribute("Y", point.Y.ToString(myNumberFormat)); elt.SetAttribute("Curve", point.Curve.ToString()); }
private static void AddNewPointInList(List <EnvelopePoint> listPoints, int x) { /* * Add new envelopes point in existing list * */ int y = 0; int index = 0; for (index = 0; index < listPoints.Count; index++) { if (x < listPoints[index].X) { if (index > 0) { /* * This code calculate the y axis according to the x position of the line * Thanks to my bro for giving me this algo * */ double x1 = listPoints[index - 1].X; double x2 = listPoints[index].X; double y1 = listPoints[index - 1].Y; double y2 = listPoints[index].Y; double a = (y2 - y1) / (x2 - x1); double b = y1 - (a * x1); y = (int)((a * x) + b); } else { y = listPoints[index].Y; } break; } else { /* if argument point is the last one and is not the only one, * it takes the y value the from previous existing point * */ if (index == listPoints.Count - 1) { y = listPoints[index].Y; index++; break; } } } // index is used to insert the point in the right position of the array EnvelopePoint newPoint = new EnvelopePoint(x, y); listPoints.Insert(index, newPoint); }
void ImportPoint(XmlElement elt, EnvelopePoints points) { Timecode x = AttributeTimecode(elt, "X"); Double y = AttributeDouble(elt, "Y"); CurveType curve = AttributeCurveType(elt, "Curve"); EnvelopePoint point = points.GetPointAtX(x); if (null == point) { point = new EnvelopePoint(x, y, curve); points.Add(point); } else { point.Y = y; point.Curve = curve; } }
public virtual void Dispose() { EnvelopePoint point = this; lock (point) { if (this.swigCPtr != IntPtr.Zero) { if (this.swigCMemOwn) { this.swigCMemOwn = false; AkSoundEnginePINVOKE.CSharp_delete_EnvelopePoint(this.swigCPtr); } this.swigCPtr = IntPtr.Zero; } GC.SuppressFinalize(this); } }
internal static HandleRef getCPtr(EnvelopePoint obj) { return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr; }
public void FromVegas(Vegas vegas) { Project proj = vegas.Project; /*foreach (Track track in proj.Tracks) * { * //Audio detection for later on... * if(track.Name == "Sync"){ * //MessageBox.Show("Audio a Sync detectado"); * foreach (TrackEvent trackEvent in track.Events) * { * if(trackEvent.MediaType == MediaType.Audio){ * * } * } * } * * }*/ foreach (Track track in proj.Tracks) { foreach (TrackEvent trackEvent in track.Events) { if (trackEvent.MediaType == MediaType.Video && trackEvent.Selected) { VideoEvent vevnt = (VideoEvent)trackEvent; Envelopes vevntEnv = vevnt.Envelopes; if (!vevntEnv.HasEnvelope(EnvelopeType.Velocity)) // Comprobamos si el video tiene envolvente { Envelope envelope = new Envelope(EnvelopeType.Velocity); vevntEnv.Add(envelope); } Envelope sensitivity = vevntEnv.FindByType(EnvelopeType.Velocity); sensitivity.Points.Clear(); Timecode timeFirst = trackEvent.Start; //Inicio del clip en milisegundos. Timecode timeLast = trackEvent.End; //Fin del clip en milisegundos. sensitivity.Points.GetPointAtX(Timecode.FromMilliseconds(0)).Y = 3; //Modificamos el valor del punto inicial foreach (Marker marker in proj.Markers) //Recorremos todos los marcadores { if (marker.Position > timeFirst && marker.Position < timeLast && marker.Label == "") // Miramos si el marcador esta dentro del video { if (sensitivity.Points.GetPointAtX(marker.Position - timeFirst) == null) // Comprobamos que no exista ya un punto en dicha posicion. { EnvelopePoint point = new EnvelopePoint(marker.Position - timeFirst, 0.15); //Creamos un nuevo punto en el marcador sensitivity.Points.Add(point); } } } EnvelopePoint pointEnd = new EnvelopePoint(timeLast, 3); //Añadimos el punto final sensitivity.Points.Add(pointEnd); } } } }
internal static HandleRef getCPtr(EnvelopePoint obj) { return((obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr); }
internal static IntPtr getCPtr(EnvelopePoint obj) { return (obj == null) ? IntPtr.Zero : obj.swigCPtr; }
public static byte[] GetEnvelopePointsValue(string[] envPoints, int sustainPoint, int loopStart, int loopEnd, bool isSustainEnabled, bool isLoopEnabled) { /* * Reproduces envelope points from renoise. * Because of sustain / loop points different logic, * might be necessary adding new point with computed y * in order to make these effects work properly * * */ if (envPoints == null) { return(new byte[0]); } List <EnvelopePoint> listPoints = new List <EnvelopePoint>(); foreach (string input in envPoints) { string[] xyValues = input.Split(','); int x = Int16.Parse(xyValues[0]); double temp = Double.Parse(xyValues[1], Culture); int y = ((int)Math.Abs(SByte.MaxValue * temp) / 2); EnvelopePoint point = new EnvelopePoint(x, y); listPoints.Add(point); } // sort is maybe not necessary because points are already sorted listPoints.Sort(); if (isSustainEnabled) { /* Check if this point already exists in Renoise, in ordet to know if it's * necessary or not to create a new one */ if (Array.BinarySearch(listPoints.ToArray(), sustainPoint) < 0) { AddNewPointInList(listPoints, sustainPoint); } } if (isLoopEnabled) { /* Check if this point already exists in Renoise, in ordet to know if it's * necessary or not to create a new one */ if (Array.BinarySearch(listPoints.ToArray(), loopStart) < 0) { AddNewPointInList(listPoints, loopStart); } /* Check if this point already exists in Renoise, in ordet to know if it's * necessary or not to create a new one */ if (Array.BinarySearch(listPoints.ToArray(), loopEnd) < 0) { AddNewPointInList(listPoints, loopEnd); } } byte[] points = new byte[listPoints.Count * 4]; int offset = 0; for (int i = 0; i < listPoints.Count; i++) { Utility.PutInt2InByteArray(listPoints[i].X, points, offset); offset += 2; Utility.PutInt2InByteArray(listPoints[i].Y, points, offset); offset += 2; } return(points); }
internal static IntPtr getCPtr(EnvelopePoint obj) { return((obj != null) ? obj.swigCPtr : IntPtr.Zero); }
internal static IntPtr getCPtr(EnvelopePoint obj) { return((obj == null) ? IntPtr.Zero : obj.swigCPtr); }