Muziek mixer probleem

Status
Niet open voor verdere reacties.

xarow

Nieuwe gebruiker
Lid geworden
9 mrt 2010
Berichten
1
hoi

ik ben met flash een muziek mixer aan het maken voor school. omdat ik winig tijd kreeg had ik er een overgenomen van het internet maar nu heb ik zeg maar 3 lijnen waar je samples met elkaar kan mixen. nu wil ik er meer hebben maar ik kan nergens in het script vinden waar dat moet.

het script is:
Code:
function initCommunications()
{
    _root.mixcomm2.dummy._visible = false;
    _root.mixcomm2.setWindowPosition(225, 100);
    _root.mixcomm.dummy._visible = false;
    _root.mixcomm.setWindowPosition(225, 100);
    _root.mixcomm.onResults = function (rv, success)
    {
        xml = new XML(rv);
        _root.windows.mixDisplay.getTreeObject().dataProvider = xml.firstChild;
        _root.mixcomm.onResults = function (rv, success)
        {
            xml = new XML(rv);
            _root.windows.sampleDisplay.getTreeObject().dataProvider = xml.firstChild;
        };
        _root.mixcomm.callWebService("getLibraryStructure", [], "Retrieving Mixes");
    };
    xml = new XML(xml_static);
    _root.windows.sampleDisplay.getTreeObject().dataProvider = xml.firstChild;
    if (_root.properties.multiSession)
    {
        _root.attachMovie("MultiUser", "multiUser", _root.getNextHighestDepth());
        _root.multiUser.dummy._visible = false;
        _root.multiUser.onNewUser = function (userObj)
        {
            if (_root.properties.channelGroups[1].getLabel() == "Remote: Not Connected")
            {
                _root.properties.channelGroups[1].setLabel("Remote: " + userObj.name);
            } // end if
        };
        _root.multiUser.onDeleteUser = function (userObj)
        {
            _root.properties.channelGroups[1].reset();
            _root.properties.channelGroups[1].setLabel("Remote: Not Connected");
        };
        _root.multiUser.onNewMessage = function (msg)
        {
            _root.controlPanel.messenger.history.text = _root.controlPanel.messenger.history.text + msg;
            _root.controlPanel.messenger.history.vPosition = _root.controlPanel.messenger.history.maxVPosition;
        };
        _root.multiUser.onSetVelocity = function (g, i, j, v)
        {
            _root.properties.channelGroups[1].setVelocity(i, j, v);
        };
        _root.multiUser.onSetChannelVolume = function (g, i, v)
        {
            _root.properties.channelGroups[1].setChannelVolume(i, v);
        };
        _root.multiUser.onSetChannelPan = function (g, i, v)
        {
            _root.properties.channelGroups[1].setChannelPan(i, v);
        };
        _root.multiUser.onSetChannelSound = function (g, i, path, file, id)
        {
            _root.properties.channelGroups[1].setChannelSound(i, path, file, id);
        };
        _root.multiUser.onInit = function (msgs, userList)
        {
            _root.controlPanel.messenger.history.text = msgs;
            _root.controlPanel.messenger.history.vPosition = _root.controlPanel.messenger.history.maxVPosition;
            for (var _loc3 in userList)
            {
                if (userList[_loc3].name != _root.properties.userName)
                {
                    _root.properties.channelGroups[1].setLabel("Remote: " + userList[_loc3].name);
                    break;
                } // end if
            } // end of for...in
            _root.properties.channelGroups[0].setLabel("Local: " + _root.properties.userName);
            _root.properties.channelGroups[0].setEnabled(true);
        };
        _root.multiUser.onDebugInfo = function (msg)
        {
            trace ("debug: " + msg);
        };
    } // end if
} // End of the function
function begin()
{
    _root.synch.stop();
    _root.synch.start(_root.properties.synchOffset, 0);
} // End of the function
function alert(ttl, msg, cncl, handler)
{
    btns = cncl ? (mx.controls.Alert.OK | mx.controls.Alert.CANCEL) : (mx.controls.Alert.OK);
    mx.controls.Alert.show(msg, ttl, btns, _root.dummy, handler, undefined, mx.controls.Alert.OK);
} // End of the function
function end()
{
    _root.synch.stop();
} // End of the function
function initMixer()
{
    _root.createEmptyMovieClip("channelGroups", 2);
    _root.channelGroups._y = 40;
    for (i = 0; i < _root.properties.frameCount; i++)
    {
        bb = _root.marker.attachMovie("bbox", "b" + i, i + 10);
        bb._x = 9 + i * 18;
        bb._y = 4;
    } // end of for
    if (_root.properties.multiSession)
    {
        _root.addGroup(0, 0, "local", 3, 3);
        _root.addGroup(0, 163, "rem", 3, 3);
    }
    else
    {
        _root.addGroup(0, 0, "local", 7, 3);
    } // end else if
    _root.arrangeComponents();
    _root.controlPanel.messenger._visible = _root.properties.multiSession;
} // End of the function
function arrangeComponents()
{
    yc = 0;
    for (g in _root.properties.channelGroups)
    {
        yc = yc + _root.properties.channelGroups[g].getHeight();
    } // end of for...in
    _root.controlPanel._y = yc + 40;
    if (!_root.properties.multiSession)
    {
    } // end if
} // End of the function
function setTempo(t)
{
    _root.properties.beatsPerSecond = t;
    _root.properties.synchOffset = 5 - 1 / _root.properties.beatsPerSecond;
    _root.controlPanel.tempoStepper.value = t;
} // End of the function
function addGroup(xc, yc, n, v, cnt)
{
    g = _root.channelGroups.attachMovie("ChannelGroup", n, _root.channelGroups.getNextHighestDepth(), {count: cnt, channelsVisible: v});
    g._x = xc;
    g._y = yc;
    g.index = _root.properties.channelGroups.push(g) - 1;
    if (_root.properties.multiSession)
    {
        g.setEnabled(false);
        if (g.index == 0)
        {
            g.onSetChannelVolume = function (i, v)
            {
                _root.multiUser.setChannelVolume(i, v);
            };
            g.onSetChannelPan = function (i, v)
            {
                _root.multiUser.setChannelPan(i, v);
            };
            g.onSetVelocity = function (i, j, v)
            {
                _root.multiUser.setVelocity(i, j, v);
            };
            g.onSetChannelSound = function (i, path, file, id)
            {
                _root.multiUser.setChannelSound(i, path, file, id);
            };
            g.setLabel("Local: Not Connected");
        }
        else
        {
            g.setLabel("Remote: Not Connected");
        } // end else if
    }
    else
    {
        g.setLabel("");
    } // end else if
    g.onResize = function ()
    {
        _root.arrangeComponents();
    };
    return (g);
} // End of the function
function saveMix()
{
    _root.mixcomm.localDone = false;
    _root.mixcomm.onResults = function (rv, success)
    {
        xmlObj = new XML();
        xmlObj.ignoreWhite = true;
        xmlObj.parseXML(rv);
        this.localDone = true;
    };
    _root.mixcomm.onEnterFrame = function ()
    {
        if (this.localDone)
        {
            delete this.localDone;
            delete this.onEnterFrame;
            _root.windows.mixDisplay.refresh();
        } // end if
    };
    _root.mixcomm.callWebService("saveMix", [_root.properties.userID, _root.toXML(), _root.properties.mixName, _root.properties.beatsPerSecond], "Retrieving Mixes");
} // End of the function
function loadMix(nam)
{
    if (_root.properties.multiSession)
    {
        var _loc2 = function (evt_obj)
        {
        };
        alert("Note", "Mixes can\'t be loaded into the multi-user mixer. Please use the single-user version for this.", false, _loc2);
    }
    else
    {
        _root.mixcomm.onResults = function (rv, success)
        {
            xmlObj = new XML();
            xmlObj.ignoreWhite = true;
            xmlObj.parseXML(rv);
            children = xmlObj.firstChild.childNodes[1].childNodes;
            format = children[0];
            _root.reInitMixer();
            _root.properties.mixName = format.attributes.name;
            _root.controlPanel.title.text = _root.properties.mixName;
            _root.setTempo(Number(format.attributes.tempo));
            grp = _root.channelGroups.local;
            for (c = 1; c < children.length; c++)
            {
                cnode = children[c];
                chnl = grp.channels[c - 1];
                if (chnl == undefined)
                {
                    chnl = grp.addChannel();
                } // end if
                sample = cnode.attributes.sample.split("/");
                chnl.setVolume(Number(cnode.attributes.volume) * 100);
                chnl.setPan(Number(cnode.attributes.pan) * 100);
                frames = cnode.attributes.value.split(":");
                for (b = 0; b < frames.length; b++)
                {
                    chnl.getSoundBox(b).setVolume(Math.round(Number(frames[b]) * 10));
                } // end of for
            } // end of for
        };
        _root.mixcomm.callWebService("getMixByTitle", [_root.properties.userID, nam], "Retrieving Mixes");
    } // end else if
} // End of the function
function reInitMixer()
{
    _root.channelGroups.removeMovieClip();
    _root.properties.channelGroups = [];
    _root.setTempo(6);
    _root.ctr = 0;
    _root.initMixer();
} // End of the function
function toXML(highq)
{
    nChannels = 0;
    nFrames = _root.properties.frameCount;
    body = "";
    for (g in _root.properties.channelGroups)
    {
        group = _root.properties.channelGroups[g];
        for (i = 0; i < group.channels.length; i++)
        {
            flag = false;
            objChannel = group.channels[i];
            chnnl = "<channel id=\'" + i + "\' sample=\'" + (highq ? (objChannel.audioSampleID.split(".")[0] + ".aif") : (objChannel.audioSampleID)) + "\' volume=\'" + objChannel.getVolume() / 100 + "\' pan=\'" + objChannel.sound.getPan() / 100 + "\' value=\'";
            for (j = 0; j < nFrames; j++)
            {
                vol = objChannel.getSoundBox(j).getVolume() / 100;
                chnnl = chnnl + (vol + ":");
                if (vol > 0)
                {
                    flag = true;
                } // end if
            } // end of for
            if (objChannel.audioSampleID != "")
            {
                if (flag)
                {
                    body = body + (chnnl.substring(0, chnnl.length - 1) + "\'/>");
                    ++nChannels;
                } // end if
            } // end if
        } // end of for
    } // end of for...in
    header = "<mix><format name=\'" + _root.properties.mixName + "\' author=\'" + _root.properties.userName + "\' channels=\'" + nChannels + "\' frames=\'" + nFrames + "\' tempo=\'" + (highq ? (_root.properties.beatsPerSecond - 2) : (_root.properties.beatsPerSecond)) + "\' volume=\'1\' pan=\'0.5\' loops=\'" + (highq ? (3) : (1)) + "\'/>";
    return (header + body + "</mix>");
} // End of the function
var main = new mx.styles.CSSStyleDeclaration();
main.setStyle("themeColor", 12637159);
main.setStyle("fontWeight", "");
main.setStyle("color", 0);
_global.styles.main = main;
SampleDisplayWindow = function (x, y, t, vis)
{
    this.win = mx.managers.PopUpManager.createPopUp(_root, mx.containers.Window, false, {title: t, closeButton: true});
    this.win.setSize(200, 215);
    this.win._x = x;
    this.win._y = y;
    this.win._visible = vis;
    Listener = new Object();
    Listener.click = function (evt)
    {
        evt.target._visible = false;
        _root.____mouseDownAllowed = true;
    };
    this.win.addEventListener("click", Listener);
    this.tree = this.win.createObject("Tree", "tree", this.win.getNextHighestDepth());
    this.tree.setStyle("styleName", "main");
    this.tree._x = 5;
    this.tree._y = 32;
    this.tree.setSize(190, 153);
    this.but = this.win.createObject("Button", "but", this.win.getNextHighestDepth());
    this.but.setStyle("styleName", "main");
    this.but.label = "Select";
    this.but._x = 5;
    this.but._y = 184;
    this.but.setSize(190, 26);
    this.but.handler = this;
    this.but.onPress = function ()
    {
        this.handler.onSelect(this._parent.tree.selectedItem.attributes.data, this._parent.tree.selectedItem.attributes.label);
    };
};
SampleDisplayWindow.prototype.onSelect = function (str)
{
};
SampleDisplayWindow.prototype.getWindowObject = function ()
{
    return (this.win);
};
SampleDisplayWindow.prototype.getTreeObject = function ()
{
    return (this.tree);
};
SampleDisplayWindow.prototype.show = function ()
{
    this.win._visible = true;
    _root.____mouseDownAllowed = false;
};
SampleDisplayWindow.prototype.hide = function ()
{
    this.win._visible = false;
    _root.____mouseDownAllowed = true;
};
MixDisplayWindow = function (x, y, t, vis)
{
    this.win = mx.managers.PopUpManager.createPopUp(_root, mx.containers.Window, false, {title: t, closeButton: true});
    this.win.setSize(200, 215);
    this.win._x = x;
    this.win._y = y;
    this.win._visible = vis;
    Listener = new Object();
    Listener.click = function (evt)
    {
        evt.target._visible = false;
        _root.____mouseDownAllowed = true;
        _root.controlPanel.btn1.setToggle("up");
    };
    this.win.addEventListener("click", Listener);
    this.tree = this.win.createObject("Tree", "tree", this.win.getNextHighestDepth());
    this.tree.setStyle("styleName", "main");
    this.tree._x = 5;
    this.tree._y = 32;
    this.tree.setSize(190, 153);
    this.but = this.win.createObject("Button", "but", this.win.getNextHighestDepth());
    this.but.setStyle("styleName", "main");
    this.but.label = "Select";
    this.but._x = 5;
    this.but._y = 184;
    this.but.setSize(190, 26);
    this.but.handler = this;
    this.but.par = this;
    this.but.onPress = function ()
    {
        _root.loadMix(this._parent.tree.selectedItem.attributes.label);
        this.par.hide();
    };
};
MixDisplayWindow.prototype.getWindowObject = function ()
{
    return (this.win);
};
MixDisplayWindow.prototype.getTreeObject = function ()
{
    return (this.tree);
};
MixDisplayWindow.prototype.show = function ()
{
    this.win._visible = true;
    _root.____mouseDownAllowed = false;
};
MixDisplayWindow.prototype.refresh = function ()
{
    _root.mixcomm.target = this.tree;
    _root.mixcomm.onResults = function (rv, success)
    {
        xml = new XML(rv);
        this.target.dataProvider = xml.firstChild;
    };
    _root.mixcomm.callWebService("getMixesByUserID", [_root.properties.userID], "Retrieving Mixes");
};
MixDisplayWindow.prototype.hide = function ()
{
    this.win._visible = false;
    _root.____mouseDownAllowed = true;
    _root.controlPanel.btn1.setToggle("up");
};
IID;
UID;
UNAME;
windows = new Object();
windows.sampleDisplay = new SampleDisplayWindow(0, 50, "Sound Library", false);
windows.mixDisplay = new MixDisplayWindow(220, 50, "My Mixes", false);
properties = new Object();
properties.multiSession = false;
properties.sessionID = IID;
properties.userName = UNAME;
properties.userID = UID;
properties.threadCount = 6;
properties.channelGroups = [];
properties.beatsPerSecond = 6;
properties.synchOffset = 5 - 1 / properties.beatsPerSecond;
properties.frameCount = 16;
properties.mixName = "Untitled-1";
ctr = 0;
____mouseDownAllowed = true;
var synch = new Sound(_root.createEmptyMovieClip("synchMC", 10));
synch.attachSound("silence");
synch.setVolume(0);
synch.onSoundComplete = function ()
{
    this.start(_root.properties.synchOffset, 0);
    _root.marker["b" + _root.ctr].play();
    for (g in _root.properties.channelGroups)
    {
        group = _root.properties.channelGroups[g];
        for (i = 0; i < group.channels.length; i++)
        {
            group.channels[i].threadedPlay(_root.ctr);
        } // end of for
    } // end of for...in
    if (_root.ctr < 15)
    {
        ++_root.ctr;
    }
    else
    {
        _root.ctr = 0;
    } // end else if
};
_root.controlPanel.title.text = _root.properties.mixName;
_root.controlPanel.title.onChanged = function ()
{
    _root.properties.mixName = this.text;
};
xml_static =
_root.createObject("Window", "dummy", _root.getNextHighestDepth());
_root.dummy._x = 285;
_root.dummy._y = 80;
_root.dummy._visible = false;
initCommunications();
initMixer();
if (_root.properties.multiSession)
{
} // end if

ik hoop dat jullie het begrijpen. alvast bedankt
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan